keith-turner closed pull request #1013: Making changes in the file according to 
issue 1011
URL: https://github.com/apache/fluo/pull/1013
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git 
a/modules/core/src/main/java/org/apache/fluo/core/async/SyncCommitObserver.java 
b/modules/core/src/main/java/org/apache/fluo/core/async/SyncCommitObserver.java
index 314859e9..c2b21dc9 100644
--- 
a/modules/core/src/main/java/org/apache/fluo/core/async/SyncCommitObserver.java
+++ 
b/modules/core/src/main/java/org/apache/fluo/core/async/SyncCommitObserver.java
@@ -16,7 +16,9 @@
 package org.apache.fluo.core.async;
 
 import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.atomic.AtomicBoolean;
 
+import com.google.common.base.Preconditions;
 import org.apache.fluo.api.exceptions.CommitException;
 import org.apache.fluo.api.exceptions.FluoException;
 import org.apache.fluo.core.exceptions.AlreadyAcknowledgedException;
@@ -28,33 +30,44 @@
   private volatile boolean aacked = false;
   private volatile Exception error = null;
   private volatile String commitFailMsg = "";
+  private AtomicBoolean isMethodCalled = new AtomicBoolean(false);
+  private static final String METHOD_CALLED_VALIDATION_CHECK_MESSAGE =
+      "One of the methods committed,failed,alreadyAcknowledged,commitFailed"
+          + " was already called";
 
   @Override
   public void committed() {
+    Preconditions.checkState(isMethodCalled.compareAndSet(false, true),
+        METHOD_CALLED_VALIDATION_CHECK_MESSAGE);
     committed = Boolean.TRUE;
     cdl.countDown();
   }
 
   @Override
   public void failed(Throwable t) {
+    Preconditions.checkState(isMethodCalled.compareAndSet(false, true),
+        METHOD_CALLED_VALIDATION_CHECK_MESSAGE);
     error = (Exception) t;
     cdl.countDown();
   }
 
   @Override
   public void alreadyAcknowledged() {
+    Preconditions.checkState(isMethodCalled.compareAndSet(false, true),
+        METHOD_CALLED_VALIDATION_CHECK_MESSAGE);
     aacked = true;
     cdl.countDown();
   }
 
   @Override
   public void commitFailed(String msg) {
+    Preconditions.checkState(isMethodCalled.compareAndSet(false, true),
+        METHOD_CALLED_VALIDATION_CHECK_MESSAGE);
     committed = false;
     commitFailMsg = msg;
     cdl.countDown();
   }
 
-
   public void waitForCommit() {
     try {
       cdl.await();


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

Reply via email to