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 {
|
abstract class AbstractAioChannel extends AbstractChannel {
|
||||||
|
|
||||||
protected AsynchronousChannel ch;
|
protected volatile AsynchronousChannel ch;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The future of the current connection attempt. If not null, subsequent
|
* The future of the current connection attempt. If not null, subsequent
|
||||||
|
@ -87,6 +87,9 @@ public class AioServerSocketChannel extends AbstractAioChannel implements Server
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected SocketAddress localAddress0() {
|
protected SocketAddress localAddress0() {
|
||||||
|
if (ch == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
try {
|
try {
|
||||||
return javaChannel().getLocalAddress();
|
return javaChannel().getLocalAddress();
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
|
@ -156,6 +156,9 @@ public class AioSocketChannel extends AbstractAioChannel implements SocketChanne
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected InetSocketAddress localAddress0() {
|
protected InetSocketAddress localAddress0() {
|
||||||
|
if (ch == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
try {
|
try {
|
||||||
return (InetSocketAddress) javaChannel().getLocalAddress();
|
return (InetSocketAddress) javaChannel().getLocalAddress();
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
@ -165,6 +168,9 @@ public class AioSocketChannel extends AbstractAioChannel implements SocketChanne
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected InetSocketAddress remoteAddress0() {
|
protected InetSocketAddress remoteAddress0() {
|
||||||
|
if (ch == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
try {
|
try {
|
||||||
return (InetSocketAddress) javaChannel().getRemoteAddress();
|
return (InetSocketAddress) javaChannel().getRemoteAddress();
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
|
Loading…
Reference in New Issue
Block a user