Author: toad
Date: 2007-09-26 14:30:06 +0000 (Wed, 26 Sep 2007)
New Revision: 15324

Modified:
   trunk/freenet/src/freenet/io/comm/FreenetInetAddress.java
Log:
Minor optimisation.
Don't catch an exception indicating a serious problem.
If the param is an IP then unconditionally set host to null; previous code 
wouldn't always work with IPv6 because there are multiple possible 
representations of many IPv6 addresses.

Modified: trunk/freenet/src/freenet/io/comm/FreenetInetAddress.java
===================================================================
--- trunk/freenet/src/freenet/io/comm/FreenetInetAddress.java   2007-09-26 
12:45:06 UTC (rev 15323)
+++ trunk/freenet/src/freenet/io/comm/FreenetInetAddress.java   2007-09-26 
14:30:06 UTC (rev 15324)
@@ -109,16 +109,12 @@
         AddressIdentifier.AddressType addressType = 
AddressIdentifier.getAddressType(host);
         boolean logDEBUG = Logger.shouldLog(Logger.DEBUG, this);
         if(logDEBUG) Logger.debug(this, "Address type of '"+host+"' appears to 
be '"+addressType+ '\'');
-        if(!addressType.toString().equals("Other")) {
-            try {
-                addr = InetAddress.getByName(host);
-            } catch (UnknownHostException e) {
-               if(!allowUnknown) throw e;
-                addr = null;
-            }
+        if(addressType != AddressIdentifier.AddressType.OTHER) {
+               // Is an IP address
+            addr = InetAddress.getByName(host);
+            // Don't catch UnknownHostException here, if it happens there's a 
bug in AddressIdentifier.
             if(logDEBUG) Logger.debug(this, "host is '"+host+"' and 
addr.getHostAddress() is '"+addr.getHostAddress()+ '\'');
-            if(addr != null && addr.getHostAddress().equals(host)) {
-               if(logDEBUG) Logger.debug(this, '\'' +host+"' looks like an IP 
address");
+            if(addr != null) {
                 host = null;
             } else {
                 addr = null;


Reply via email to