Issue Details (XML | Word | Printable)

Key: NUCMONGODB-106
Type: Bug Bug
Status: Closed Closed
Resolution: Fixed
Priority: Major Major
Assignee: Unassigned
Reporter: Vincent Chen
Votes: 0
Watchers: 0
Operations

If you were logged in you would be able to see more operations.
DataNucleus Store MongoDB

Multiple servers configuration is not handled properly

Created: 21/Sep/12 11:24 PM   Updated: 24/Sep/12 03:17 PM   Resolved: 24/Sep/12 02:47 PM
Component/s: None
Affects Version/s: 3.1.0.release
Fix Version/s: 3.1.2

Datastore: MongoDB
Severity: Production


 Description  « Hide
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('/');


Sort Order: Ascending order - Click to sort in descending order
Andy Jefferson added a comment - 24/Sep/12 02:47 PM
Typo of variable name fixed in SVN trunk.