Michael Blow has uploaded a new change for review.

  https://asterix-gerrit.ics.uci.edu/1275

Change subject: DO NOT MERGE: Audit Incorrect Uses Of SynchronizableWork
......................................................................

DO NOT MERGE: Audit Incorrect Uses Of SynchronizableWork

Change-Id: I39b6c2cf764799e5b2a0846cd4b23660d24f4cb7
---
M 
hyracks-fullstack/hyracks/hyracks-control/hyracks-control-common/src/main/java/org/apache/hyracks/control/common/work/SynchronizableWork.java
1 file changed, 10 insertions(+), 0 deletions(-)


  git pull ssh://asterix-gerrit.ics.uci.edu:29418/asterixdb 
refs/changes/75/1275/1

diff --git 
a/hyracks-fullstack/hyracks/hyracks-control/hyracks-control-common/src/main/java/org/apache/hyracks/control/common/work/SynchronizableWork.java
 
b/hyracks-fullstack/hyracks/hyracks-control/hyracks-control-common/src/main/java/org/apache/hyracks/control/common/work/SynchronizableWork.java
index f9952db..f597021 100644
--- 
a/hyracks-fullstack/hyracks/hyracks-control/hyracks-control-common/src/main/java/org/apache/hyracks/control/common/work/SynchronizableWork.java
+++ 
b/hyracks-fullstack/hyracks/hyracks-control/hyracks-control-common/src/main/java/org/apache/hyracks/control/common/work/SynchronizableWork.java
@@ -23,6 +23,8 @@
 
 public abstract class SynchronizableWork extends AbstractWork {
     private boolean done;
+    private boolean runCalled;
+    private boolean syncCalled;
 
     private Exception e;
 
@@ -35,6 +37,7 @@
 
     @Override
     public final void run() {
+        runCalled = true;
         try {
             doRun();
         } catch (Exception ex) {
@@ -49,6 +52,7 @@
     }
 
     public final synchronized void sync() throws Exception {
+        syncCalled = true;
         while (!done) {
             wait();
         }
@@ -56,4 +60,10 @@
             throw e;
         }
     }
+
+    protected void finalize() throws Throwable {
+        if (runCalled && !syncCalled) {
+            Logger.getLogger(getClass().getName()).severe("instance of 
SynchronizableWork not sync()'d");
+        }
+    }
 }

-- 
To view, visit https://asterix-gerrit.ics.uci.edu/1275
To unsubscribe, visit https://asterix-gerrit.ics.uci.edu/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I39b6c2cf764799e5b2a0846cd4b23660d24f4cb7
Gerrit-PatchSet: 1
Gerrit-Project: asterixdb
Gerrit-Branch: master
Gerrit-Owner: Michael Blow <mb...@apache.org>

Reply via email to