Skip to content

Commit 91d1805

Browse files
committed
JAVA-1040: Make BulkOperation throw IllegalStateException if executed more than once or with an empty list up updates.
1 parent 07180e4 commit 91d1805

File tree

1 file changed

+4
-10
lines changed

1 file changed

+4
-10
lines changed

src/main/com/mongodb/BulkWriteOperation.java

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -80,11 +80,8 @@ public BulkWriteRequestBuilder find(final DBObject query) {
8080
public BulkWriteResult execute() {
8181
isTrue("already executed", !closed);
8282

83-
try {
84-
return collection.executeBulkWriteOperation(ordered, requests);
85-
} finally {
86-
closed = true;
87-
}
83+
closed = true;
84+
return collection.executeBulkWriteOperation(ordered, requests);
8885
}
8986

9087
/**
@@ -99,11 +96,8 @@ public BulkWriteResult execute() {
9996
public BulkWriteResult execute(final WriteConcern writeConcern) {
10097
isTrue("already executed", !closed);
10198

102-
try {
103-
return collection.executeBulkWriteOperation(ordered, requests, writeConcern);
104-
} finally {
105-
closed = true;
106-
}
99+
closed = true;
100+
return collection.executeBulkWriteOperation(ordered, requests, writeConcern);
107101
}
108102

109103
void addRequest(final WriteRequest request) {

0 commit comments

Comments
 (0)