Uploaded image for project: 'Java Driver'
  1. Java Driver
  2. JAVA-955

Space in Database Name Should Be Considered Invalid

    • Type: Icon: Bug Bug
    • Resolution: Done
    • Priority: Icon: Minor - P4 Minor - P4
    • 2.12.0, 3.0.0
    • Affects Version/s: None
    • Component/s: API
    • Labels:
      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 Unassigned
            Reporter:
            stephen.lee Stephen Lee
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: