Skip to content

Commit dcbef5e

Browse files
committed
Correctly guard against NotYetConnectedExceptions when handling RDHUP.
Motivation: Commit 2c1f17f introduced a regression which could cause NotYetConnectedExceptions when handling RDHUP events. Modifications: Correct ignore NotYetConnectedException when handling RDHUP events. Result: No more regression.
1 parent 53d4950 commit dcbef5e

File tree

1 file changed

+14
-3
lines changed

1 file changed

+14
-3
lines changed

transport-native-epoll/src/main/java/io/netty/channel/epoll/AbstractEpollChannel.java

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
import java.io.IOException;
3434
import java.net.InetSocketAddress;
3535
import java.nio.ByteBuffer;
36+
import java.nio.channels.NotYetConnectedException;
3637
import java.nio.channels.UnresolvedAddressException;
3738

3839
import static io.netty.util.internal.ObjectUtil.checkNotNull;
@@ -348,19 +349,29 @@ void shutdownInput() {
348349
try {
349350
fd().shutdown(true, false);
350351
clearEpollIn0();
351-
pipeline().fireUserEventTriggered(ChannelInputShutdownEvent.INSTANCE);
352352
} catch (IOException ignored) {
353353
// We attempted to shutdown and failed, which means the input has already effectively been
354354
// shutdown.
355-
pipeline().fireUserEventTriggered(ChannelInputShutdownEvent.INSTANCE);
356-
close(voidPromise());
355+
fireEventAndClose(ChannelInputShutdownEvent.INSTANCE);
356+
return;
357+
} catch (NotYetConnectedException ignore) {
358+
// We attempted to shutdown and failed, which means the input has already effectively been
359+
// shutdown.
360+
fireEventAndClose(ChannelInputShutdownEvent.INSTANCE);
361+
return;
357362
}
363+
pipeline().fireUserEventTriggered(ChannelInputShutdownEvent.INSTANCE);
358364
} else {
359365
close(voidPromise());
360366
}
361367
}
362368
}
363369

370+
private void fireEventAndClose(Object evt) {
371+
pipeline().fireUserEventTriggered(evt);
372+
close(voidPromise());
373+
}
374+
364375
@Override
365376
protected void flush0() {
366377
// Flush immediately only when there's no pending flush.

0 commit comments

Comments
 (0)