Permalink
Browse files

JAVA-619: throwing IllegalArgumentException from all public update me…

…thods that take a write concern if the write concern is null
  • Loading branch information...
1 parent 3fb3f07 commit 5283b51a4727ca536f64f58e3f043f1e2ea8183c @jyemin jyemin committed Aug 14, 2012
Showing with 17 additions and 0 deletions.
  1. +13 −0 src/main/com/mongodb/DBApiLayer.java
  2. +4 −0 src/main/com/mongodb/DBTCPConnector.java
@@ -197,6 +197,11 @@ public void drop(){
}
public WriteResult insert(DBObject[] arr, com.mongodb.WriteConcern concern, DBEncoder encoder ){
+
+ if (concern == null) {
+ throw new IllegalArgumentException("Write concern can not be null");
+ }
+
return insert( arr, true, concern, encoder );
}
@@ -249,6 +254,10 @@ protected WriteResult insert(DBObject[] arr, boolean shouldApply , com.mongodb.W
public WriteResult remove( DBObject o , com.mongodb.WriteConcern concern, DBEncoder encoder ){
+ if (concern == null) {
+ throw new IllegalArgumentException("Write concern can not be null");
+ }
+
if (encoder == null)
encoder = DefaultDBEncoder.FACTORY.create();
@@ -296,6 +305,10 @@ public WriteResult update( DBObject query , DBObject o , boolean upsert , boolea
throw new IllegalArgumentException("update can not be null");
}
+ if (concern == null) {
+ throw new IllegalArgumentException("Write concern can not be null");
+ }
+
if (encoder == null)
encoder = DefaultDBEncoder.FACTORY.create();
@@ -165,6 +165,10 @@ public WriteResult say( DB db , OutMessage m , WriteConcern concern ){
@Override
public WriteResult say( DB db , OutMessage m , WriteConcern concern , ServerAddress hostNeeded ){
+ if (concern == null) {
+ throw new IllegalArgumentException("Write concern is null");
+ }
+
_checkClosed();
checkMaster( false , true );

0 comments on commit 5283b51

Please sign in to comment.