[JAVA-1644] NPE on createIndex when the database name contains a "." Created: 08/Feb/15 Updated: 29/Nov/16 Resolved: 03/Nov/16 |
|
| Status: | Closed |
| Project: | Java Driver |
| Component/s: | Command Operations |
| Affects Version/s: | 2.13.0 |
| Fix Version/s: | 3.4.0 |
| Type: | Bug | Priority: | Major - P3 |
| Reporter: | Colm McDonnell | Assignee: | Jeffrey Yemin |
| Resolution: | Done | Votes: | 0 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Issue Links: |
|
||||||||||||||||||||
| Description |
|
I'm getting a NPE from the Mongo Java driver when calling createIndex on a DBCollection in a database which has a full stop (aka period, ".") in its name. Here's the exception ...
Here's a reproduction test case:
|
| Comments |
| Comment by Githook User [ 03/Nov/16 ] | |||||||||||||
|
Author: {u'username': u'jyemin', u'name': u'Jeff Yemin', u'email': u'jeff.yemin@10gen.com'}Message: Add static helper methods to MongoNamespace for checking validity prior to construction Check validity of database name and collection name in high-level API | |||||||||||||
| Comment by Jeffrey Yemin [ 17/Oct/16 ] | |||||||||||||
|
To prevent an obscure error message from being reported, the driver should validate that database names don't contain a '.'. | |||||||||||||
| Comment by Jeffrey Yemin [ 17/Oct/16 ] | |||||||||||||
|
It appears that the reason the reply contains no documents is that the server treats it is a query on the 1.$cmd collection, which does not exist, rather than a command. The suggested fix in | |||||||||||||
| Comment by Colm McDonnell [ 09/Feb/15 ] | |||||||||||||
|
Hi Ross, I have added my own validation before calling the Mongo Java driver, so it's not affecting me now. I raised the JIRA to (a) get confirmation that this is a reserved character and (b) see if the driver could be changed to handle this as a known failure rather than a NPE. So, your response hit the nail on the head, thanks! | |||||||||||||
| Comment by Ross Lawley [ 09/Feb/15 ] | |||||||||||||
|
Hi [colmmcd, The database name is not valid as /\ " . are invalid characters on all systems and there are a few more invalid names for Windows systems - see: naming restrictions. This explains why theres an error and I'll investigate why a null pointer error is being thrown rather than the invalid namespace error that I'd expect. | |||||||||||||
| Comment by Colm McDonnell [ 08/Feb/15 ] | |||||||||||||
|
Here's the control test case, to show that the same code runs successfully when the databaseName does not contain a full stop ...
|