[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Bug classpath/28035] New: java.rmi.server.UID does not return unique ID
From: |
dpirkle at symyx dot com |
Subject: |
[Bug classpath/28035] New: java.rmi.server.UID does not return unique IDs |
Date: |
15 Jun 2006 02:59:36 -0000 |
A loop like the following will show duplicate ID's returned by the toString()
method of java.rmi.server.UID:
for (int i = 1; i <=20; ++i) {
System.out.println(new UID().toString());
}
Within the first few lines, you'll see an ID that appears twice in two
consecutive lines.
I believe the problem is due to this line at the end of the constructor:
count = uidCounter++;
Any time the clock advances, count and uidCounter are set to Short.MIN_VALUE.
The next iteration, the else branch is taken, and count will stay at
Short.MIN_VALUE, since a postfix operator is used on uidCounter (see line
above). All subsequent iterations, count and uidCounter will continue to
increment, until the clock ticks again, at which point the duplication
reocccurs.
If I change the line above to the following, it seems to fix the problem:
count = ++uidCounter;
By the way, shouldn't the whole constructor be synchronized? Seems like
there's potential for what's going on in the if branch to conflict with what's
going on in the else branch (if you had 2 threads at each branch at the same
time), but the if is not synchronized and the else is synchronized, so one can
clobber the other.
--
Summary: java.rmi.server.UID does not return unique IDs
Product: classpath
Version: 0.91
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: classpath
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: dpirkle at symyx dot com
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=28035
- [Bug classpath/28035] New: java.rmi.server.UID does not return unique IDs,
dpirkle at symyx dot com <=
- [Bug classpath/28035] java.rmi.server.UID does not return unique IDs, audriusa at bluewin dot ch, 2006/06/18
- [Bug classpath/28035] java.rmi.server.UID does not return unique IDs, audriusa at bluewin dot ch, 2006/06/18
- [Bug classpath/28035] java.rmi.server.UID does not return unique IDs, audriusa at bluewin dot ch, 2006/06/18
- [Bug classpath/28035] java.rmi.server.UID does not return unique IDs, jeroen at frijters dot net, 2006/06/19
- [Bug classpath/28035] java.rmi.server.UID does not return unique IDs, audriusa at bluewin dot ch, 2006/06/19
- [Bug classpath/28035] java.rmi.server.UID does not return unique IDs, audriusa at bluewin dot ch, 2006/06/19
- [Bug classpath/28035] java.rmi.server.UID does not return unique IDs, audriusa at bluewin dot ch, 2006/06/19