Skip to content

Commit e8e2bc8

Browse files
author
Brendan W. McAdams
committed
JAVA-425: WriteConcern in "Default" (W < 0) passes through empty getLastError to allow use of getLastErrorDefaults setting on server
1 parent f9180ed commit e8e2bc8

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/main/com/mongodb/WriteConcern.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -242,8 +242,10 @@ public WriteConcern( String w , int wtimeout , boolean fsync, boolean j , Boolea
242242
public BasicDBObject getCommand(){
243243
BasicDBObject _command = new BasicDBObject( "getlasterror" , 1 );
244244

245-
_command.put( "w" , _wValue );
246-
_command.put( "wtimeout" , _wtimeout );
245+
if ( _wValue instanceof Integer && ( (Integer) _wValue > 0) ){
246+
_command.put( "w" , _wValue );
247+
_command.put( "wtimeout" , _wtimeout );
248+
}
247249

248250
if ( _fsync )
249251
_command.put( "fsync" , true );

0 commit comments

Comments
 (0)