summaryrefslogtreecommitdiff
path: root/java/rmi
diff options
context:
space:
mode:
authorAudrius Meskauskas <audriusa@Bioinformatics.org>2006-03-08 21:42:45 +0000
committerAudrius Meskauskas <audriusa@Bioinformatics.org>2006-03-08 21:42:45 +0000
commit6ba3e86a9226bff9db51c220066d90bddbf0aa86 (patch)
tree91d4d00b0b3a5abc6c2642e138328386c5f341f0 /java/rmi
parent527949a7b8b0a25712d7ff7c140baf163c36b878 (diff)
downloadclasspath-6ba3e86a9226bff9db51c220066d90bddbf0aa86.tar.gz
2006-03-08 Audrius Meskauskas <AudriusA@Bioinformatics.org>
* java/rmi/server/UID.java (getMachineId): Include the host IP address.
Diffstat (limited to 'java/rmi')
-rw-r--r--java/rmi/server/UID.java19
1 files changed, 18 insertions, 1 deletions
diff --git a/java/rmi/server/UID.java b/java/rmi/server/UID.java
index 1951ff3cc..75cb9f6be 100644
--- a/java/rmi/server/UID.java
+++ b/java/rmi/server/UID.java
@@ -42,6 +42,7 @@ import java.io.DataInput;
import java.io.DataOutput;
import java.io.IOException;
import java.io.Serializable;
+import java.net.InetAddress;
/**
* Represents the unique identifier over time for the host which has generated
@@ -187,10 +188,26 @@ public final class UID
*/
static int getMachineId()
{
+ int hostIpHash;
+
+ try
+ {
+ // Try to get the host IP.
+ String host = InetAddress.getLocalHost().toString();
+ // This hash is content - based, not the address based.
+ hostIpHash = host.hashCode();
+ }
+ catch (Exception e)
+ {
+ // Failed due some reason.
+ hostIpHash = 0;
+ }
+
// Should be the unque address if hashcodes are addresses.
// Additionally, add the time when the RMI system was probably started
// (this class was first instantiated).
- return UID.class.hashCode() + (int) System.currentTimeMillis();
+ return new Object().hashCode() ^ (int) System.currentTimeMillis()
+ ^ hostIpHash;
}
/**