Skip to content

Commit

Permalink
Replace all that stuff with try catch
Browse files Browse the repository at this point in the history
  • Loading branch information
burmanm committed Aug 21, 2023
1 parent f1521c2 commit 804ff22
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
import com.google.common.collect.ImmutableMap;
import com.google.common.util.concurrent.Uninterruptibles;
import io.netty.handler.codec.http.FullHttpResponse;
import io.netty.util.IllegalReferenceCountException;
import java.io.IOException;
import java.net.URI;
import java.net.URISyntaxException;
Expand Down Expand Up @@ -788,11 +789,18 @@ public void testAsyncRepair() throws IOException, URISyntaxException, Interrupte
.atMost(Duration.ofMinutes(5))
.untilAsserted(
() -> {
Pair<Integer, String> getJobDetailsResponse =
client
.get(getJobDetailsUri.toURL())
.thenApply(this::responseAsCodeAndBody)
.join();
Pair<Integer, String> getJobDetailsResponse;
try {
getJobDetailsResponse =
client
.get(getJobDetailsUri.toURL())
.thenApply(this::responseAsCodeAndBody)
.join();
} catch (IllegalReferenceCountException e) {
// Just retry
assertFalse(true);
return;
}
assertThat(getJobDetailsResponse.getLeft()).isEqualTo(HttpStatus.SC_OK);
Map<String, String> jobDetails =
new JsonMapper()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
import com.google.common.util.concurrent.Uninterruptibles;
import io.netty.bootstrap.Bootstrap;
import io.netty.channel.Channel;
import io.netty.channel.ChannelFuture;
import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.ChannelInitializer;
import io.netty.channel.EventLoopGroup;
Expand Down Expand Up @@ -181,9 +180,7 @@ private CompletableFuture<FullHttpResponse> buildAndSendRequest(HttpMethod metho
request.headers().set(HttpHeaderNames.HOST, url.getHost());

// Send the HTTP request.
ChannelFuture channelFuture = client.writeAndFlush(request).awaitUninterruptibly();
channelFuture.syncUninterruptibly();
channelFuture.channel().closeFuture().syncUninterruptibly();
client.writeAndFlush(request);

return result;
}
Expand Down

0 comments on commit 804ff22

Please sign in to comment.