Return immediately when the given BatchWrite is empty
This revision aims to remove empty check of BatchWrite in the caller
side of this method
Change-Id: Ic0d659a6da221a052ad135eba18a783caa81ec42
diff --git a/core/api/src/main/java/org/onosproject/net/intent/IntentStore.java b/core/api/src/main/java/org/onosproject/net/intent/IntentStore.java
index 452cd97..cb71266 100644
--- a/core/api/src/main/java/org/onosproject/net/intent/IntentStore.java
+++ b/core/api/src/main/java/org/onosproject/net/intent/IntentStore.java
@@ -112,6 +112,7 @@
/**
* Execute writes in a batch.
+ * If the specified BatchWrite is empty, write will not be executed.
*
* @param batch BatchWrite to execute
* @return failed operations
diff --git a/core/store/dist/src/main/java/org/onosproject/store/intent/impl/DistributedIntentStore.java b/core/store/dist/src/main/java/org/onosproject/store/intent/impl/DistributedIntentStore.java
index 556f4cb..ef6d086 100644
--- a/core/store/dist/src/main/java/org/onosproject/store/intent/impl/DistributedIntentStore.java
+++ b/core/store/dist/src/main/java/org/onosproject/store/intent/impl/DistributedIntentStore.java
@@ -54,6 +54,7 @@
import org.slf4j.Logger;
import java.util.ArrayList;
+import java.util.Collections;
import java.util.EnumSet;
import java.util.HashSet;
import java.util.List;
@@ -416,6 +417,9 @@
@Override
public List<Operation> batchWrite(BatchWrite batch) {
+ if (batch.isEmpty()) {
+ return Collections.emptyList();
+ }
List<Operation> failed = new ArrayList<>();
final Builder builder = BatchWriteRequest.newBuilder();
diff --git a/core/store/dist/src/main/java/org/onosproject/store/intent/impl/HazelcastIntentStore.java b/core/store/dist/src/main/java/org/onosproject/store/intent/impl/HazelcastIntentStore.java
index 39255c8..667d2a8 100644
--- a/core/store/dist/src/main/java/org/onosproject/store/intent/impl/HazelcastIntentStore.java
+++ b/core/store/dist/src/main/java/org/onosproject/store/intent/impl/HazelcastIntentStore.java
@@ -54,6 +54,7 @@
import org.slf4j.Logger;
import java.util.ArrayList;
+import java.util.Collections;
import java.util.EnumSet;
import java.util.List;
import java.util.Map;
@@ -394,6 +395,10 @@
@Override
public List<Operation> batchWrite(BatchWrite batch) {
+ if (batch.isEmpty()) {
+ return Collections.emptyList();
+ }
+
// Hazelcast version will never fail for conditional failure now.
List<Operation> failed = new ArrayList<>();
diff --git a/core/store/trivial/src/main/java/org/onosproject/store/trivial/impl/SimpleIntentStore.java b/core/store/trivial/src/main/java/org/onosproject/store/trivial/impl/SimpleIntentStore.java
index 5f0ad2b..ce687b5 100644
--- a/core/store/trivial/src/main/java/org/onosproject/store/trivial/impl/SimpleIntentStore.java
+++ b/core/store/trivial/src/main/java/org/onosproject/store/trivial/impl/SimpleIntentStore.java
@@ -33,6 +33,7 @@
import org.onosproject.store.AbstractStore;
import org.slf4j.Logger;
+import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
@@ -154,6 +155,10 @@
*/
@Override
public List<Operation> batchWrite(BatchWrite batch) {
+ if (batch.isEmpty()) {
+ return Collections.emptyList();
+ }
+
List<Operation> failed = Lists.newArrayList();
for (Operation op : batch.operations()) {
switch (op.type()) {