Skip to content

Commit 5283b51

Browse files
committed
JAVA-619: throwing IllegalArgumentException from all public update methods that take a write concern if the write concern is null
1 parent 3fb3f07 commit 5283b51

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed

src/main/com/mongodb/DBApiLayer.java

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,11 @@ public void drop(){
197197
}
198198

199199
public WriteResult insert(DBObject[] arr, com.mongodb.WriteConcern concern, DBEncoder encoder ){
200+
201+
if (concern == null) {
202+
throw new IllegalArgumentException("Write concern can not be null");
203+
}
204+
200205
return insert( arr, true, concern, encoder );
201206
}
202207

@@ -249,6 +254,10 @@ protected WriteResult insert(DBObject[] arr, boolean shouldApply , com.mongodb.W
249254

250255
public WriteResult remove( DBObject o , com.mongodb.WriteConcern concern, DBEncoder encoder ){
251256

257+
if (concern == null) {
258+
throw new IllegalArgumentException("Write concern can not be null");
259+
}
260+
252261
if (encoder == null)
253262
encoder = DefaultDBEncoder.FACTORY.create();
254263

@@ -296,6 +305,10 @@ public WriteResult update( DBObject query , DBObject o , boolean upsert , boolea
296305
throw new IllegalArgumentException("update can not be null");
297306
}
298307

308+
if (concern == null) {
309+
throw new IllegalArgumentException("Write concern can not be null");
310+
}
311+
299312
if (encoder == null)
300313
encoder = DefaultDBEncoder.FACTORY.create();
301314

src/main/com/mongodb/DBTCPConnector.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,10 @@ public WriteResult say( DB db , OutMessage m , WriteConcern concern ){
165165
@Override
166166
public WriteResult say( DB db , OutMessage m , WriteConcern concern , ServerAddress hostNeeded ){
167167

168+
if (concern == null) {
169+
throw new IllegalArgumentException("Write concern is null");
170+
}
171+
168172
_checkClosed();
169173
checkMaster( false , true );
170174

0 commit comments

Comments
 (0)