This class cannot handle multiple servers configuration string for connecting to Mongo replicaset.
The bug is at line 101: int serverEndPos = remains.indexOf('/');
'remains' is the substring after "mongodb:", and it never gets changed to "" as intended, because the code is trying to split every comma-separated token with the same "serverEndPos" again and again.
The second DB instance name will be interpreted as "anotherhost.foo", which is truncated with the index of the "/" in entire 'remains' string.
The fix is simply to replace int serverEndPos = remains.indexOf('/'); with int serverEndPos = token.indexOf('/');
Description
http://datanucleus.svn.sourceforge.net/viewvc/datanucleus/platform/store.mongodb/trunk/src/java/org/datanucleus/store/mongodb/ConnectionFactoryImpl.java?revision=15556&view=markup
This class cannot handle multiple servers configuration string for connecting to Mongo replicaset.
The bug is at line 101: int serverEndPos = remains.indexOf('/');
'remains' is the substring after "mongodb:", and it never gets changed to "" as intended, because the code is trying to split every comma-separated token with the same "serverEndPos" again and again.
E.g., connectionURL mongodb:localhost:27017/stores,anotherhost.foo.com
The second DB instance name will be interpreted as "anotherhost.foo", which is truncated with the index of the "/" in entire 'remains' string.
The fix is simply to replace int serverEndPos = remains.indexOf('/'); with int serverEndPos = token.indexOf('/');