Skip to content

Commit 224e6b0

Browse files
committed
- JAVA-425: fix cast exception in case W is a String
1 parent fefab8c commit 224e6b0

File tree

1 file changed

+7
-11
lines changed

1 file changed

+7
-11
lines changed

src/main/com/mongodb/WriteConcern.java

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -269,28 +269,24 @@ public boolean getFsync(){
269269
return _fsync;
270270
}
271271

272-
/**
273-
* Returns whether (batch) inserts will continue if an error occurs before the end
274-
* @return boolean
275-
*/
276-
public boolean continueOnErrorForInsert(){
277-
return _continueOnErrorInsert;
278-
}
279-
280272
/**
281273
* Returns whether network error may be raised (w >= 0)
282274
* @return
283275
*/
284276
public boolean raiseNetworkErrors(){
285-
return (Integer) _wValue >= 0;
277+
if (_wValue instanceof Integer)
278+
return (Integer) _wValue >= 0;
279+
return _wValue != null;
286280
}
287281

288282
/**
289283
* Returns whether "getlasterror" should be called (w > 0)
290284
* @return
291285
*/
292286
public boolean callGetLastError(){
293-
return (Integer) _wValue > 0;
287+
if (_wValue instanceof Integer)
288+
return (Integer) _wValue > 0;
289+
return _wValue != null;
294290
}
295291

296292
/**
@@ -321,7 +317,7 @@ public static WriteConcern valueOf(String name) {
321317

322318
@Override
323319
public String toString(){
324-
return "WriteConcern " + getCommand() + " / (Continue Inserting on Errors? " + continueOnErrorForInsert() + ")";
320+
return "WriteConcern " + getCommand() + " / (Continue Inserting on Errors? " + _continueOnErrorInsert + ")";
325321
}
326322

327323
@Override

0 commit comments

Comments
 (0)