Details
-
Bug
-
Resolution: Cannot Reproduce
-
Major - P3
-
None
-
1.2
-
None
-
None
-
MacOSX 10.6.2 JDK 1.6
Description
In a test class the following code
List<DBObject> users = new ArrayList<DBObject>();
users.add(new BasicDBObject(userOne.toMap()));
users.add(new BasicDBObject(userTwo.toMap()));
users.add(new BasicDBObject(userThree.toMap()));
repo.getCollection().insert(users);
produce the same ObjectID for each userXXX inserted
I see in the driver the "algorithm":
private static int _nextInc = (new java.util.Random()).nextInt();
private static int _gentime = _flip( (int)(System.currentTimeMillis()/1000) );
Suggestion:
With an "algorithm" like this :
public static String calculateUniqueId() {
long number = System.currentTimeMillis() * 1000 + (long) (Math.random() * 1000);
return Long.toString(number, 25);
}
I have ids different for each userXXX in the same test where ObjectID fails