Use a logger in SocketAddresses

This commit is contained in:
Cruz Bishop 2012-04-15 17:29:15 +10:00
parent d363f73fd8
commit db97e4eb35

View File

@ -15,6 +15,8 @@
*/ */
package io.netty.util; package io.netty.util;
import io.netty.logging.InternalLogger;
import io.netty.logging.InternalLoggerFactory;
import java.net.InetAddress; import java.net.InetAddress;
import java.net.UnknownHostException; import java.net.UnknownHostException;
@ -22,6 +24,9 @@ public final class SocketAddresses {
public static final InetAddress LOCALHOST; public static final InetAddress LOCALHOST;
private static final InternalLogger logger =
InternalLoggerFactory.getInstance(SocketAddresses.class);
static { static {
// We cache this because some machine takes almost forever to return // We cache this because some machine takes almost forever to return
// from InetAddress.getLocalHost(). I think it's due to the incorrect // from InetAddress.getLocalHost(). I think it's due to the incorrect
@ -36,8 +41,7 @@ public final class SocketAddresses {
try { try {
localhost = InetAddress.getByAddress(new byte[] { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1 }); localhost = InetAddress.getByAddress(new byte[] { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1 });
} catch (UnknownHostException e2) { } catch (UnknownHostException e2) {
System.err.println("Failed to get the localhost."); logger.error("Failed to resolve localhost", e2);
e2.printStackTrace();
} }
} }
} }