summaryrefslogtreecommitdiff
path: root/java/net
diff options
context:
space:
mode:
authorAndrew John Hughes <gnu_andrew@member.fsf.org>2006-06-11 18:23:15 +0000
committerAndrew John Hughes <gnu_andrew@member.fsf.org>2006-06-11 18:23:15 +0000
commit35d18ccf396a6cfdcbe5bbdf38df7d01852250bc (patch)
tree562e6d161a8957db8a46900b46f661c5e52e1a34 /java/net
parentc5877847749d21bdf84e33929ffa52a56e5c6ca0 (diff)
downloadclasspath-35d18ccf396a6cfdcbe5bbdf38df7d01852250bc.tar.gz
2006-06-11 Andrew John Hughes <gnu_andrew@member.fsf.org>
* Merge of HEAD-->generics between 2006/05/29 and 2006/06/11.
Diffstat (limited to 'java/net')
-rw-r--r--java/net/InetSocketAddress.java9
1 files changed, 6 insertions, 3 deletions
diff --git a/java/net/InetSocketAddress.java b/java/net/InetSocketAddress.java
index 912545752..5267cc11a 100644
--- a/java/net/InetSocketAddress.java
+++ b/java/net/InetSocketAddress.java
@@ -86,7 +86,6 @@ public class InetSocketAddress extends SocketAddress
this.addr = addr;
this.port = port;
- this.hostname = addr.getHostName();
}
/**
@@ -186,7 +185,7 @@ public class InetSocketAddress extends SocketAddress
if (addr == null && sa.addr != null)
return false;
- else if (addr == null && sa.addr == null)
+ else if (addr == null && sa.addr == null) // we know hostname != null
return hostname.equals(sa.hostname) && sa.port == port;
else
return addr.equals(sa.addr) && sa.port == port;
@@ -213,6 +212,9 @@ public class InetSocketAddress extends SocketAddress
*/
public final String getHostName()
{
+ if (hostname == null) // we know addr != null
+ hostname = addr.getHostName();
+
return hostname;
}
@@ -249,10 +251,11 @@ public class InetSocketAddress extends SocketAddress
/**
* Returns the <code>InetSocketAddress</code> as string
*
- * @return A string represenation of this address.
+ * @return A string representation of this address.
*/
public String toString()
{
+ // Note: if addr is null, then hostname != null.
return (addr == null ? hostname : addr.toString()) + ":" + port;
}
}