Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@
import io.trino.sql.planner.plan.PlanNode;
import io.trino.sql.planner.plan.PlanNodeId;
import io.trino.tracing.TrinoAttributes;
import jakarta.ws.rs.ServiceUnavailableException;
import org.joda.time.DateTime;

import java.net.URI;
Expand Down Expand Up @@ -127,6 +128,7 @@
import static java.lang.Math.addExact;
import static java.lang.Math.clamp;
import static java.lang.String.format;
import static java.net.HttpURLConnection.HTTP_UNAVAILABLE;
import static java.util.Objects.requireNonNull;
import static java.util.concurrent.TimeUnit.NANOSECONDS;

Expand Down Expand Up @@ -976,7 +978,7 @@ private void doScheduleAsyncCleanupRequest(Backoff cleanupBackoff, Request reque
public void onSuccess(JsonResponse<TaskInfo> result)
{
if (result.getStatusCode() != OK.code()) {
onFailure(new RuntimeException("Unexpected http status code " + result.getStatusCode()));
onFailure(exceptionForErrorCode(result));
return;
}

Expand All @@ -993,6 +995,14 @@ public void onSuccess(JsonResponse<TaskInfo> result)
}
}

private static RuntimeException exceptionForErrorCode(JsonResponse<TaskInfo> result)
{
return switch (result.getStatusCode()) {
case HTTP_UNAVAILABLE -> new ServiceUnavailableException("Service Unavailable");
default -> new RuntimeException("Unexpected http status code " + result.getStatusCode());
};
}

@Override
@SuppressWarnings("FormatStringAnnotation") // we manipulate the format string and there's no way to make Error Prone accept the result
public void onFailure(Throwable t)
Expand Down
Loading