[JAVA-299] MongoUri does not work accoring to documentation Created: 18/Mar/11 Updated: 16/Nov/21 Resolved: 21/Apr/11 |
|
| Status: | Closed |
| Project: | Java Driver |
| Component/s: | API |
| Affects Version/s: | 2.5 |
| Fix Version/s: | 2.6 |
| Type: | Bug | Priority: | Major - P3 |
| Reporter: | Ragnar Aas | Assignee: | Scott Hernandez (Inactive) |
| Resolution: | Done | Votes: | 1 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Environment: |
Windows 7, Spring 3, Java. |
||
| Description |
|
I tried using the documented format for the URI : But got an "String index out of range" error in line 69 of MongoUri-class. Upon examining the code, I see the problem : if ( serverPart.indexOf( "@" ) > 0 ) { int idx = serverPart.indexOf( "@" ); _username = serverPart.substring( 0 , idx ); serverPart = serverPart.substring( idx + 1 ); idx = serverPart.indexOf( ":" ); Line 69 : _password = serverPart.substring( 0 , idx ).toCharArray(); serverPart = serverPart.substring( idx + 1 ); }In the above, I am guessing the problem is two-fold. 1) In retrieving the password, you are using "serverPart" instead of "_username" . But now the "serverPart" parameter holds everything behind "@". In the above code, using "serverPart" instead of "_username", the correct usage would be : mongodb://<username>@<password>:<server>/<db-name>.<db-collection> But I am guessing this is wrong. I have tried the above, and see that this does not throw an exception. |
| Comments |
| Comment by auto [ 21/Apr/11 ] |
|
Author: {u'login': u'rcugut', u'name': u'Radu Cugut', u'email': u'rcugut@gmail.com'}Message: Bugfix: |
| Comment by Radu Cugut [ 19/Apr/11 ] |
|
Same problem with our code. Using 2.5.3. We hacked it to use the form user@pass:hostname. But recently, we took advantage of the fact this is an open-source project and fixed it in the code and pushed a maven artifact in our private repo There is a pull-request on github that fixes this |