Fixes the problem where the promise of the outbound operation that causes a channel closure is notified after channelInactive()
- Fixes #1897
This commit is contained in:
parent
e307979a0d
commit
d7f9b1ee76
@ -477,8 +477,8 @@ public abstract class AbstractChannel extends DefaultAttributeMap implements Cha
|
||||
try {
|
||||
doBind(localAddress);
|
||||
} catch (Throwable t) {
|
||||
closeIfClosed();
|
||||
promise.setFailure(t);
|
||||
closeIfClosed();
|
||||
return;
|
||||
}
|
||||
if (!wasActive && isActive()) {
|
||||
@ -498,8 +498,8 @@ public abstract class AbstractChannel extends DefaultAttributeMap implements Cha
|
||||
try {
|
||||
doDisconnect();
|
||||
} catch (Throwable t) {
|
||||
closeIfClosed();
|
||||
promise.setFailure(t);
|
||||
closeIfClosed();
|
||||
return;
|
||||
}
|
||||
if (wasActive && !isActive()) {
|
||||
@ -510,8 +510,8 @@ public abstract class AbstractChannel extends DefaultAttributeMap implements Cha
|
||||
}
|
||||
});
|
||||
}
|
||||
closeIfClosed(); // doDisconnect() might have closed the channel
|
||||
promise.setSuccess();
|
||||
closeIfClosed(); // doDisconnect() might have closed the channel
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -35,6 +35,7 @@ import java.nio.channels.ClosedChannelException;
|
||||
import java.nio.channels.ConnectionPendingException;
|
||||
import java.nio.channels.NotYetConnectedException;
|
||||
import java.util.ArrayDeque;
|
||||
import java.util.Collections;
|
||||
import java.util.Queue;
|
||||
|
||||
/**
|
||||
@ -293,9 +294,7 @@ public class LocalChannel extends AbstractChannel {
|
||||
peerLoop.execute(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
for (int i = 0; i < msgsCopy.length; i++) {
|
||||
peer.inboundBuffer.add(msgsCopy[i]);
|
||||
}
|
||||
Collections.addAll(peer.inboundBuffer, msgsCopy);
|
||||
finishPeerRead(peer, peerPipeline);
|
||||
}
|
||||
});
|
||||
@ -350,7 +349,6 @@ public class LocalChannel extends AbstractChannel {
|
||||
doBind(localAddress);
|
||||
} catch (Throwable t) {
|
||||
promise.setFailure(t);
|
||||
pipeline().fireExceptionCaught(t);
|
||||
close(voidPromise());
|
||||
return;
|
||||
}
|
||||
|
@ -210,8 +210,8 @@ public abstract class AbstractNioChannel extends AbstractChannel {
|
||||
newT.setStackTrace(t.getStackTrace());
|
||||
t = newT;
|
||||
}
|
||||
closeIfClosed();
|
||||
promise.tryFailure(t);
|
||||
closeIfClosed();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -80,8 +80,8 @@ public abstract class AbstractOioChannel extends AbstractChannel {
|
||||
newT.setStackTrace(t.getStackTrace());
|
||||
t = newT;
|
||||
}
|
||||
closeIfClosed();
|
||||
promise.setFailure(t);
|
||||
closeIfClosed();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user