Buggy code:
public class Mongo { public static final int MAJOR_VERSION = 2 ; public static final int MINOR_VERSION = 7 ; static int cleanerIntervalMS ; public static DB connect ( DBAddress addr ) { } public Mongo ( ) throws MongoException , UnknownHostException { } public Mongo ( String host ) throws MongoException , UnknownHostException { } public Mongo ( String host , MongoOptions options ) throws MongoException , UnknownHostException { } public Mongo ( String host , int port ) throws MongoException , UnknownHostException { } public Mongo ( ServerAddress addr ) throws MongoException { } public Mongo ( ServerAddress addr , MongoOptions options ) throws MongoException { } @ Deprecated public Mongo ( ServerAddress left , ServerAddress right ) throws MongoException { } @ Deprecated public Mongo ( ServerAddress left , ServerAddress right , MongoOptions options ) throws MongoException { } public Mongo ( List < ServerAddress > replicaSetSeeds ) throws MongoException { } public Mongo ( List < ServerAddress > replicaSetSeeds , MongoOptions options ) throws MongoException { } public Mongo ( MongoURI uri ) throws MongoException , UnknownHostException { } public DB getDB ( String dbname ) { } public DB getDBWithAdminCommandOnCreation ( String dbname , DBObject cmd ) { DB db = _dbs . get ( dbname ) ; if ( db != null ) return db ; db = new DBApiLayer ( this , dbname , _connector ) ; DB temp = _dbs . putIfAbsent ( dbname , db ) ; <START_BUG> if ( cmd != null ) { <END_BUG> getDB ( "admin" ) . command ( cmd ) ; } if ( temp != null ) return temp ; return db ; } public DB getShardedDB ( String dbname ) { } public Collection < DB > getUsedDatabases ( ) { } public List < String > getDatabaseNames ( ) throws MongoException { } public void dropDatabase ( String dbName ) throws MongoException { } public String getVersion ( ) { } public String debugString ( ) { } public String getConnectPoint ( ) { } public DBTCPConnector getConnector ( ) { } public ReplicaSetStatus getReplicaSetStatus ( ) { } public ServerAddress getAddress ( ) { } public List < ServerAddress > getAllAddress ( ) { } public List < ServerAddress > getServerAddressList ( ) { } public void close ( ) { } public void setWriteConcern ( WriteConcern concern ) { } public WriteConcern getWriteConcern ( ) { } public void setReadPreference ( ReadPreference preference ) { } public ReadPreference getReadPreference ( ) { } @ Deprecated public void slaveOk ( ) { } public void addOption ( int option ) { } public void setOptions ( int options ) { } public void resetOptions ( ) { } public int getOptions ( ) { } @ SuppressWarnings ( "deprecation" ) void _applyMongoOptions ( ) { } public MongoOptions getMongoOptions ( ) { } public int getMaxBsonObjectSize ( ) { } final ServerAddress _addr ; final List < ServerAddress > _addrs ; final MongoOptions _options ; final DBTCPConnector _connector ; final ConcurrentMap < String , DB > _dbs = new ConcurrentHashMap < String , DB > ( ) ; private WriteConcern _concern = WriteConcern . NORMAL ; private ReadPreference _readPref = ReadPreference . PRIMARY ; final OptionHolder _netOptions = new Bytes . OptionHolder ( null ) ; final Mongo . DBCleanerThread _cleaner ; SimplePool < PoolOutputBuffer > _bufferPool = new SimplePool < PoolOutputBuffer > ( 1000 ) { protected PoolOutputBuffer createNew ( ) { } } ; public CommandResult fsync ( boolean async ) { } public CommandResult fsyncAndLock ( ) { } public DBObject unlock ( ) { } public boolean isLocked ( ) { } public static class Holder { public Mongo connect ( MongoURI uri ) throws MongoException , UnknownHostException { } String _toKey ( MongoURI uri ) { } public static Mongo . Holder singleton ( ) { } private static Mongo . Holder _default = new Mongo . Holder ( ) ; private final ConcurrentMap < String , Mongo > _mongos = new ConcurrentHashMap < String , Mongo > ( ) ; } class DBCleanerThread extends Thread { DBCleanerThread ( ) { } public void run ( ) { } } @ Override public String toString ( ) { } }

Fix:
if ( ( cmd != null ) && ( temp == null ) ) {