Allow to access localAddress and remoteAddress even if the channel is not registered yet

This commit is contained in:
Norman Maurer 2012-12-14 15:19:03 +01:00
parent 42f6a27235
commit 6eb7de04e7
3 changed files with 10 additions and 1 deletions

View File

@ -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

View File

@ -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) {

View File

@ -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) {