Use InetSocketAddress.getHostName() instead of getHostString()
Related: #3478 Motivation: DefaultNameResolver uses InetSocketAddress.getHostString() instead of getHostName(). Because Netty uses the DefaultNameResolver by default and getHostString() is available only since Java 7, a user cannot use Netty on Java 6 anymore. Modifications: Use InetSocketAddress.getHostName() which is practically same and also is available in Java 6. Result: Netty 4.1 runs on Java 6 again.
This commit is contained in:
parent
ec097f61b4
commit
4aa10db9c5
@ -41,10 +41,10 @@ public class DefaultNameResolver extends SimpleNameResolver<InetSocketAddress> {
|
||||
@Override
|
||||
protected void doResolve(InetSocketAddress unresolvedAddress, Promise<InetSocketAddress> promise) throws Exception {
|
||||
try {
|
||||
promise.setSuccess(
|
||||
new InetSocketAddress(
|
||||
InetAddress.getByName(unresolvedAddress.getHostString()),
|
||||
unresolvedAddress.getPort()));
|
||||
// Note that InetSocketAddress.getHostName() will never incur a reverse lookup here,
|
||||
// because an unresolved address always has a host name.
|
||||
promise.setSuccess(new InetSocketAddress(
|
||||
InetAddress.getByName(unresolvedAddress.getHostName()), unresolvedAddress.getPort()));
|
||||
} catch (UnknownHostException e) {
|
||||
promise.setFailure(e);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user