Description
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.
Attachments
Issue Links
- related to
-
SERVER-10891 Commands don't return "ok" field if targeting databases with invalid characters
-
- Closed
-
-
JAVA-956 Assume {ok:0} in case of missing 'ok' field in server response
-
- Closed
-