From f9b1563bdd466662df8a7b86087f1d6312fa5f86 Mon Sep 17 00:00:00 2001 From: Greg Burd Date: Wed, 24 Jan 2018 16:11:44 -0500 Subject: [PATCH] Ensure there is a batch. --- src/main/java/net/helenus/core/operation/BatchOperation.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/net/helenus/core/operation/BatchOperation.java b/src/main/java/net/helenus/core/operation/BatchOperation.java index 13685a4..41763ec 100644 --- a/src/main/java/net/helenus/core/operation/BatchOperation.java +++ b/src/main/java/net/helenus/core/operation/BatchOperation.java @@ -29,12 +29,13 @@ import net.helenus.core.UnitOfWork; import net.helenus.support.HelenusException; public class BatchOperation extends Operation { - private BatchStatement batch = null; + private final BatchStatement batch; private List> operations = new ArrayList>(); private boolean logged = true; public BatchOperation(AbstractSessionOperations sessionOperations) { super(sessionOperations); + batch = new BatchStatement(); } public void add(AbstractOperation operation) { @@ -43,7 +44,6 @@ public class BatchOperation extends Operation { @Override public BatchStatement buildStatement(boolean cached) { - batch = new BatchStatement(); batch.addAll( operations.stream().map(o -> o.buildStatement(cached)).collect(Collectors.toList())); batch.setConsistencyLevel(sessionOps.getDefaultConsistencyLevel());