InetAddress.java (getLocalHost): Refactor to avoid security check if getLocalHostname() fails and to provide...
2006-09-01 Gary Benson <gbenson@redhat.com> * java/net/InetAddress.java (getLocalHost): Refactor to avoid security check if getLocalHostname() fails and to provide more meaningful exceptions it the security check fails. From-SVN: r116627
This commit is contained in:
parent
429b876b07
commit
69afd3217e
|
@ -1,3 +1,9 @@
|
||||||
|
2006-09-01 Gary Benson <gbenson@redhat.com>
|
||||||
|
|
||||||
|
* java/net/InetAddress.java (getLocalHost): Refactor to avoid
|
||||||
|
security check if getLocalHostname() fails and to provide more
|
||||||
|
meaningful exceptions it the security check fails.
|
||||||
|
|
||||||
2006-09-01 Gary Benson <gbenson@redhat.com>
|
2006-09-01 Gary Benson <gbenson@redhat.com>
|
||||||
|
|
||||||
* java/net/InetAddress.java (getByAddress): Create Inet4Address
|
* java/net/InetAddress.java (getByAddress): Create Inet4Address
|
||||||
|
|
|
@ -706,7 +706,10 @@ public class InetAddress implements Serializable
|
||||||
|
|
||||||
String hostname = getLocalHostname();
|
String hostname = getLocalHostname();
|
||||||
|
|
||||||
if (s != null)
|
if (hostname == null || hostname.length() == 0)
|
||||||
|
throw new UnknownHostException();
|
||||||
|
|
||||||
|
try
|
||||||
{
|
{
|
||||||
// "The Java Class Libraries" suggests that if the security
|
// "The Java Class Libraries" suggests that if the security
|
||||||
// manager disallows getting the local host name, then
|
// manager disallows getting the local host name, then
|
||||||
|
@ -714,22 +717,13 @@ public class InetAddress implements Serializable
|
||||||
// However, the JDK 1.2 API claims to throw SecurityException,
|
// However, the JDK 1.2 API claims to throw SecurityException,
|
||||||
// which seems to suggest SecurityException is *not* caught.
|
// which seems to suggest SecurityException is *not* caught.
|
||||||
// In this case, experimentation shows that former is correct.
|
// In this case, experimentation shows that former is correct.
|
||||||
try
|
if (s != null)
|
||||||
{
|
{
|
||||||
// This is wrong, if the name returned from getLocalHostname()
|
// This is wrong, if the name returned from getLocalHostname()
|
||||||
// is not a fully qualified name. FIXME.
|
// is not a fully qualified name. FIXME.
|
||||||
s.checkConnect (hostname, -1);
|
s.checkConnect (hostname, -1);
|
||||||
}
|
}
|
||||||
catch (SecurityException ex)
|
|
||||||
{
|
|
||||||
hostname = null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (hostname != null && hostname.length() != 0)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
localhost = new InetAddress (null, null);
|
localhost = new InetAddress (null, null);
|
||||||
lookup (hostname, localhost, false);
|
lookup (hostname, localhost, false);
|
||||||
}
|
}
|
||||||
|
@ -740,12 +734,6 @@ public class InetAddress implements Serializable
|
||||||
throw failure;
|
throw failure;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
|
||||||
throw new UnknownHostException();
|
|
||||||
|
|
||||||
if (localhost == null)
|
|
||||||
localhost = new InetAddress (loopbackAddress, "localhost");
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Needed for serialization
|
* Needed for serialization
|
||||||
|
|
Loading…
Reference in New Issue