Skip to content

Commit

Permalink
#4717 remove null check in doClose and change test so that it does no…
Browse files Browse the repository at this point in the history
…t pass a null key to the ctor

Signed-off-by: Ludovic Orban <lorban@bitronix.be>
  • Loading branch information
lorban committed May 11, 2022
1 parent f781462 commit 0fc317b
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 5 deletions.
Expand Up @@ -207,8 +207,7 @@ public void doClose()
LOG.debug("doClose {}", this);
try
{
if (_key != null)
_key.cancel();
_key.cancel();
_channel.close();
}
catch (IOException e)
Expand Down
Expand Up @@ -19,6 +19,9 @@
package org.eclipse.jetty.io;

import java.nio.ByteBuffer;
import java.nio.channels.SelectableChannel;
import java.nio.channels.SelectionKey;
import java.nio.channels.Selector;
import java.nio.channels.ServerSocketChannel;
import java.nio.channels.SocketChannel;

Expand Down Expand Up @@ -58,9 +61,51 @@ public static void close() throws Exception
private EndPointPair newConnection() throws Exception
{
EndPointPair c = new EndPointPair();

c.client = new SocketChannelEndPoint(SocketChannel.open(connector.socket().getLocalSocketAddress()), null, null, null);
c.server = new SocketChannelEndPoint(connector.accept(), null, null, null);
SelectionKey k = new SelectionKey()
{
@Override
public SelectableChannel channel()
{
throw new UnsupportedOperationException();
}

@Override
public Selector selector()
{
throw new UnsupportedOperationException();
}

@Override
public boolean isValid()
{
throw new UnsupportedOperationException();
}

@Override
public void cancel()
{
}

@Override
public int interestOps()
{
throw new UnsupportedOperationException();
}

@Override
public SelectionKey interestOps(int ops)
{
throw new UnsupportedOperationException();
}

@Override
public int readyOps()
{
throw new UnsupportedOperationException();
}
};
c.client = new SocketChannelEndPoint(SocketChannel.open(connector.socket().getLocalSocketAddress()), null, k, null);
c.server = new SocketChannelEndPoint(connector.accept(), null, k, null);
return c;
}

Expand Down

0 comments on commit 0fc317b

Please sign in to comment.