Skip to content

Commit

Permalink
try-catch
Browse files Browse the repository at this point in the history
  • Loading branch information
ywangd committed Oct 29, 2024
1 parent 885433d commit f40c2dc
Showing 1 changed file with 6 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
import io.netty.channel.ChannelFutureListener;
import io.netty.handler.codec.http.HttpContent;
import io.netty.handler.codec.http.LastHttpContent;
import io.netty.util.concurrent.Future;

import org.elasticsearch.core.Releasables;
import org.elasticsearch.http.HttpBody;
Expand Down Expand Up @@ -67,17 +66,16 @@ public void addTracingHandler(ChunkHandler chunkHandler) {
public void next() {
assert closing == false : "cannot request next chunk on closing stream";
assert handler != null : "handler must be set before requesting next chunk";
final Future<?> future = channel.eventLoop().submit(() -> {
channel.eventLoop().submit(() -> {
requested = true;
if (buf == null) {
channel.read();
} else {
send();
}
});
future.addListener(f -> {
if (f.isSuccess() == false) {
channel.eventLoop().submit(() -> channel.pipeline().fireExceptionCaught(f.cause()));
try {
send();
} catch (Exception e) {
channel.pipeline().fireExceptionCaught(e);
}
}
});
}
Expand Down

0 comments on commit f40c2dc

Please sign in to comment.