Allow to access localAddress and remoteAddress even if the channel is not registered yet
This commit is contained in:
parent
42f6a27235
commit
6eb7de04e7
@ -29,7 +29,7 @@ import java.util.concurrent.TimeUnit;
|
||||
|
||||
abstract class AbstractAioChannel extends AbstractChannel {
|
||||
|
||||
protected AsynchronousChannel ch;
|
||||
protected volatile AsynchronousChannel ch;
|
||||
|
||||
/**
|
||||
* The future of the current connection attempt. If not null, subsequent
|
||||
|
@ -87,6 +87,9 @@ public class AioServerSocketChannel extends AbstractAioChannel implements Server
|
||||
|
||||
@Override
|
||||
protected SocketAddress localAddress0() {
|
||||
if (ch == null) {
|
||||
return null;
|
||||
}
|
||||
try {
|
||||
return javaChannel().getLocalAddress();
|
||||
} catch (IOException e) {
|
||||
|
@ -156,6 +156,9 @@ public class AioSocketChannel extends AbstractAioChannel implements SocketChanne
|
||||
|
||||
@Override
|
||||
protected InetSocketAddress localAddress0() {
|
||||
if (ch == null) {
|
||||
return null;
|
||||
}
|
||||
try {
|
||||
return (InetSocketAddress) javaChannel().getLocalAddress();
|
||||
} catch (IOException e) {
|
||||
@ -165,6 +168,9 @@ public class AioSocketChannel extends AbstractAioChannel implements SocketChanne
|
||||
|
||||
@Override
|
||||
protected InetSocketAddress remoteAddress0() {
|
||||
if (ch == null) {
|
||||
return null;
|
||||
}
|
||||
try {
|
||||
return (InetSocketAddress) javaChannel().getRemoteAddress();
|
||||
} catch (IOException e) {
|
||||
|
Loading…
Reference in New Issue
Block a user