Skip to content

Commit

Permalink
Check response status of the abort task results request
Browse files Browse the repository at this point in the history
  • Loading branch information
arhimondr authored and martint committed Nov 4, 2021
1 parent c3f73b8 commit 92387da
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@
import static com.google.common.base.Preconditions.checkState;
import static com.google.common.base.Strings.isNullOrEmpty;
import static com.google.common.net.HttpHeaders.CONTENT_TYPE;
import static io.airlift.http.client.HttpStatus.NO_CONTENT;
import static io.airlift.http.client.HttpStatus.familyForStatusCode;
import static io.airlift.http.client.Request.Builder.prepareDelete;
import static io.airlift.http.client.Request.Builder.prepareGet;
Expand Down Expand Up @@ -469,6 +470,15 @@ private synchronized void sendDelete()
public void onSuccess(@Nullable StatusResponse result)
{
assertNotHoldsLock(this);

if (result.getStatusCode() != NO_CONTENT.code()) {
onFailure(new TrinoTransportException(
REMOTE_BUFFER_CLOSE_FAILED,
fromUri(location),
format("Error closing remote buffer, expected %s got %s", NO_CONTENT.code(), result.getStatusCode())));
return;
}

backoff.success();
synchronized (HttpPageBufferClient.this) {
closed = true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -293,6 +293,7 @@ public void testInvalidResponses()
assertStatus(client, location, "queued", 0, 3, 3, 3, "not scheduled");

// close client and verify
processor.setResponse(new TestingResponse(HttpStatus.NO_CONTENT, ImmutableListMultimap.of(), new byte[0]));
client.close();
requestComplete.await(10, TimeUnit.SECONDS);
assertStatus(client, location, "closed", 0, 3, 4, 3, "not scheduled");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public Response handle(Request request)
ImmutableList<String> parts = ImmutableList.copyOf(Splitter.on("/").omitEmptyStrings().split(request.getUri().getPath()));
if (request.getMethod().equals("DELETE")) {
assertEquals(parts.size(), 1);
return new TestingResponse(HttpStatus.OK, ImmutableListMultimap.of(), new byte[0]);
return new TestingResponse(HttpStatus.NO_CONTENT, ImmutableListMultimap.of(), new byte[0]);
}

assertEquals(parts.size(), 2);
Expand Down

0 comments on commit 92387da

Please sign in to comment.