Skip to content

Commit b4e9558

Browse files
author
Stephane Landelle
committed
Minor clean up
1 parent 551142a commit b4e9558

File tree

2 files changed

+6
-18
lines changed

2 files changed

+6
-18
lines changed

src/main/java/com/ning/http/client/providers/netty/request/NettyRequestSender.java

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

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

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

349-
} catch (Throwable ioe) {
340+
} catch (Throwable t) {
341+
LOGGER.error("Can't write request", t);
350342
Channels.silentlyCloseChannel(channel);
351343
}
352344
}

src/main/java/com/ning/http/client/providers/netty/request/ProgressListener.java

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

0 commit comments

Comments
 (0)