Potential fix for NETTY-52 (IllegalArgumentException when trying to change the current interestOps)
This commit is contained in:
parent
731ab2a0eb
commit
cfa6794292
@ -628,7 +628,7 @@ public class Channels {
|
||||
*/
|
||||
public static ChannelFuture setInterestOps(Channel channel, int interestOps) {
|
||||
validateInterestOps(interestOps);
|
||||
validateDownstreamInterestOps(channel, interestOps);
|
||||
interestOps = filterDownstreamInterestOps(interestOps);
|
||||
|
||||
ChannelFuture future = future(channel);
|
||||
channel.getPipeline().sendDownstream(new DefaultChannelStateEvent(
|
||||
@ -650,7 +650,7 @@ public class Channels {
|
||||
ChannelHandlerContext ctx, Channel channel,
|
||||
ChannelFuture future, int interestOps) {
|
||||
validateInterestOps(interestOps);
|
||||
validateDownstreamInterestOps(channel, interestOps);
|
||||
interestOps = filterDownstreamInterestOps(interestOps);
|
||||
|
||||
ctx.sendDownstream(
|
||||
new DefaultChannelStateEvent(
|
||||
@ -733,10 +733,8 @@ public class Channels {
|
||||
}
|
||||
}
|
||||
|
||||
private static void validateDownstreamInterestOps(Channel channel, int interestOps) {
|
||||
if (((channel.getInterestOps() ^ interestOps) & Channel.OP_WRITE) != 0) {
|
||||
throw new IllegalArgumentException("OP_WRITE can't be modified by user.");
|
||||
}
|
||||
private static int filterDownstreamInterestOps(int interestOps) {
|
||||
return interestOps & ~Channel.OP_WRITE;
|
||||
}
|
||||
|
||||
private Channels() {
|
||||
|
@ -763,6 +763,10 @@ class NioWorker implements Runnable {
|
||||
fireExceptionCaught(channel, cause);
|
||||
}
|
||||
|
||||
// Override OP_WRITE flag - a user cannot change this flag.
|
||||
interestOps &= ~Channel.OP_WRITE;
|
||||
interestOps |= channel.getInterestOps() & Channel.OP_WRITE;
|
||||
|
||||
boolean changed = false;
|
||||
try {
|
||||
switch (CONSTRAINT_LEVEL) {
|
||||
|
@ -126,6 +126,10 @@ class OioWorker implements Runnable {
|
||||
static void setInterestOps(
|
||||
OioSocketChannel channel, ChannelFuture future, int interestOps) {
|
||||
|
||||
// Override OP_WRITE flag - a user cannot change this flag.
|
||||
interestOps &= ~Channel.OP_WRITE;
|
||||
interestOps |= channel.getInterestOps() & Channel.OP_WRITE;
|
||||
|
||||
boolean changed = false;
|
||||
try {
|
||||
if (channel.getInterestOps() != interestOps) {
|
||||
|
Loading…
Reference in New Issue
Block a user