Space in Database Name Should Be Considered Invalid

XMLWordPrintableJSON

    • Type: Bug
    • Resolution: Done
    • Priority: Minor - P4
    • 2.12.0, 3.0.0
    • Affects Version/s: None
    • Component/s: API
    • None
    • None
    • None
    • None
    • None
    • None
    • None
    • None

      Per this documentation, database names should not include the space character. However, the driver will submit a database command that includes space and return a dubious response.

      Reproduction code against mongos:

      import com.mongodb.*;
      
      public class Test {
      	public static final String DBNAME = "test asdfasdf";
      	
      	public static void main( String[] args ) throws Exception {
      		Mongo mongo = new Mongo( "localhost", 27020 );
      		DB db = mongo.getDB( DBNAME );
      		db.getCollection( "test").insert(new BasicDBObject("a",1));
      	
      		try {
      		    db.requestStart();
      		    db.requestEnsureConnection();
      		    while (true) {
      		        try {
      		            mongo.dropDatabase( DBNAME );
      		            break;
      		        } catch (MongoException ex) {
      		        	ex.printStackTrace();
      		          // Do error handling, omitted for shortness here.
      		        }
      		    }
      		} finally {
      		    db.requestDone();
      		}
      	}
      }
      

      This will trigger a "ok should never be null" exception.

          There are no Sub-Tasks for this issue.

              Assignee:
              Unassigned
              Reporter:
              Stephen Lee (Inactive)
              None
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

                Created:
                Updated:
                Resolved: