Permalink
Browse files

JAVA-486: Synchronized DBTCPConnector._set method to eliminate race c…

…ondition on log message
  • Loading branch information...
jyemin committed Mar 12, 2012
1 parent bff8c71 commit 43db979f9bef63ee60cdda449dc8fcaf9b4353ef
Showing with 2 additions and 2 deletions.
  1. +2 −2 src/main/com/mongodb/DBTCPConnector.java
@@ -473,12 +473,12 @@ int fetchMaxBsonObjectSize() {
return _maxBsonObjectSize.get();
}
- private boolean _set( ServerAddress addr ){
+ private synchronized boolean _set( ServerAddress addr ){
DBPortPool newPool = _portHolder.get( addr );
if (newPool == _masterPortPool)
return false;
- if ( _logger.isLoggable( Level.WARNING ) && _masterPortPool != null )
+ if ( _masterPortPool != null )
_logger.log(Level.WARNING, "Master switching from " + _masterPortPool.getServerAddress() + " to " + addr);
_masterPortPool = newPool;
return true;

0 comments on commit 43db979

Please sign in to comment.