Skip to content

Commit 282a6e8

Browse files
author
Stephane Landelle
committed
minor clean up
1 parent c94ca3c commit 282a6e8

File tree

4 files changed

+10
-31
lines changed

4 files changed

+10
-31
lines changed

providers/netty3/src/main/java/org/asynchttpclient/providers/netty3/request/NettyRequestSender.java

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -323,17 +323,9 @@ public <T> void writeRequest(NettyResponseFuture<T> future, Channel channel) {
323323
configureTransferAdapter(handler, httpRequest);
324324

325325
if (!future.isHeadersAlreadyWrittenOnContinue()) {
326-
try {
327326
if (future.getAsyncHandler() instanceof AsyncHandlerExtensions)
328327
AsyncHandlerExtensions.class.cast(future.getAsyncHandler()).onSendRequest(nettyRequest);
329328
channel.write(httpRequest).addListener(new ProgressListener(config, future.getAsyncHandler(), future, true));
330-
} catch (Throwable cause) {
331-
// FIXME why not notify?
332-
LOGGER.debug(cause.getMessage(), cause);
333-
// FIXME what about the attribute? how could this fail?
334-
Channels.silentlyCloseChannel(channel);
335-
return;
336-
}
337329
}
338330

339331
// FIXME what happens to this second write if the first one failed? Should it be done in the ProgressListener?
@@ -345,7 +337,8 @@ public <T> void writeRequest(NettyResponseFuture<T> future, Channel channel) {
345337
if (Channels.isChannelValid(channel))
346338
scheduleTimeouts(future);
347339

348-
} catch (Throwable ioe) {
340+
} catch (Throwable t) {
341+
LOGGER.error("Can't write request", t);
349342
Channels.silentlyCloseChannel(channel);
350343
}
351344
}

providers/netty3/src/main/java/org/asynchttpclient/providers/netty3/request/ProgressListener.java

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -51,11 +51,7 @@ private boolean abortOnThrowable(Throwable cause, Channel channel) {
5151
if (cause != null && future.getState() != NettyResponseFuture.STATE.NEW) {
5252
// The write operation failed. If the channel was cached, it means it got asynchronously closed.
5353
// Let's retry a second time.
54-
if (cause instanceof IllegalStateException) {
55-
LOGGER.debug(cause.getMessage(), cause);
56-
Channels.silentlyCloseChannel(channel);
57-
58-
} else if (cause instanceof ClosedChannelException || StackTraceInspector.abortOnReadOrWriteException(cause)) {
54+
if (cause instanceof IllegalStateException || cause instanceof ClosedChannelException || StackTraceInspector.abortOnReadOrWriteException(cause)) {
5955
LOGGER.debug(cause == null ? "" : cause.getMessage(), cause);
6056
Channels.silentlyCloseChannel(channel);
6157

providers/netty4/src/main/java/org/asynchttpclient/providers/netty4/request/NettyRequestSender.java

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -318,17 +318,10 @@ public <T> void writeRequest(NettyResponseFuture<T> future, Channel channel) {
318318
configureTransferAdapter(handler, httpRequest);
319319

320320
if (!future.isHeadersAlreadyWrittenOnContinue()) {
321-
try {
322-
if (future.getAsyncHandler() instanceof AsyncHandlerExtensions)
323-
AsyncHandlerExtensions.class.cast(future.getAsyncHandler()).onSendRequest(nettyRequest);
324-
325-
channel.writeAndFlush(httpRequest, channel.newProgressivePromise()).addListener(new ProgressListener(config, future.getAsyncHandler(), future, true, 0L));
326-
} catch (Throwable cause) {
327-
// FIXME why not notify?
328-
LOGGER.debug(cause.getMessage(), cause);
329-
Channels.silentlyCloseChannel(channel);
330-
return;
331-
}
321+
if (future.getAsyncHandler() instanceof AsyncHandlerExtensions)
322+
AsyncHandlerExtensions.class.cast(future.getAsyncHandler()).onSendRequest(nettyRequest);
323+
324+
channel.writeAndFlush(httpRequest, channel.newProgressivePromise()).addListener(new ProgressListener(config, future.getAsyncHandler(), future, true, 0L));
332325
}
333326

334327
if (!future.isDontWriteBodyBecauseExpectContinue() && !httpRequest.getMethod().equals(HttpMethod.CONNECT) && nettyRequest.getBody() != null)
@@ -338,7 +331,8 @@ public <T> void writeRequest(NettyResponseFuture<T> future, Channel channel) {
338331
if (Channels.isChannelValid(channel))
339332
scheduleTimeouts(future);
340333

341-
} catch (Throwable ioe) {
334+
} catch (Throwable t) {
335+
LOGGER.error("Can't write request", t);
342336
Channels.silentlyCloseChannel(channel);
343337
}
344338
}

providers/netty4/src/main/java/org/asynchttpclient/providers/netty4/request/ProgressListener.java

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -55,11 +55,7 @@ public ProgressListener(AsyncHttpClientConfig config,//
5555
private boolean abortOnThrowable(Throwable cause, Channel channel) {
5656

5757
if (cause != null && future.getState() != NettyResponseFuture.STATE.NEW) {
58-
if (cause instanceof IllegalStateException) {
59-
LOGGER.debug(cause.getMessage(), cause);
60-
Channels.silentlyCloseChannel(channel);
61-
62-
} else if (cause instanceof ClosedChannelException || StackTraceInspector.abortOnReadOrWriteException(cause)) {
58+
if (cause instanceof IllegalStateException || cause instanceof ClosedChannelException || StackTraceInspector.abortOnReadOrWriteException(cause)) {
6359
LOGGER.debug(cause.getMessage(), cause);
6460
Channels.silentlyCloseChannel(channel);
6561

0 commit comments

Comments
 (0)