You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ofbiz.apache.org by mb...@apache.org on 2017/10/13 20:57:01 UTC

svn commit: r1812163 - /ofbiz/ofbiz-framework/trunk/framework/service/src/main/java/org/apache/ofbiz/service/semaphore/ServiceSemaphore.java

Author: mbrohl
Date: Fri Oct 13 20:57:01 2017
New Revision: 1812163

URL: http://svn.apache.org/viewvc?rev=1812163&view=rev
Log:
Improved: Fixing defects reported by FindBugs, package 
org.apache.ofbiz.service.semaphore.
(OFBIZ-9693)

Thanks Dennis Balkir for reporting and providing the patch.

Modified:
    ofbiz/ofbiz-framework/trunk/framework/service/src/main/java/org/apache/ofbiz/service/semaphore/ServiceSemaphore.java

Modified: ofbiz/ofbiz-framework/trunk/framework/service/src/main/java/org/apache/ofbiz/service/semaphore/ServiceSemaphore.java
URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/framework/service/src/main/java/org/apache/ofbiz/service/semaphore/ServiceSemaphore.java?rev=1812163&r1=1812162&r2=1812163&view=diff
==============================================================================
--- ofbiz/ofbiz-framework/trunk/framework/service/src/main/java/org/apache/ofbiz/service/semaphore/ServiceSemaphore.java (original)
+++ ofbiz/ofbiz-framework/trunk/framework/service/src/main/java/org/apache/ofbiz/service/semaphore/ServiceSemaphore.java Fri Oct 13 20:57:01 2017
@@ -70,7 +70,7 @@ public class ServiceSemaphore {
         }
     }
 
-    public void release() throws SemaphoreFailException {
+    public synchronized void release() throws SemaphoreFailException {
         if (mode == SEMAPHORE_MODE_NONE) return;
 
         // remove the lock file
@@ -138,10 +138,9 @@ public class ServiceSemaphore {
 
             // we own the lock, no waiting
             return false;
-        } else {
-            // found a semaphore, need to wait
-            return true;
         }
+        // found a semaphore, need to wait
+        return true;
     }
 
     private synchronized void dbWrite(GenericValue value, boolean delete) throws SemaphoreFailException {
@@ -180,7 +179,7 @@ public class ServiceSemaphore {
                         Debug.logError(e, module);
                     }
                 }
-                if (!isError && beganTx) {
+                if (!isError) {
                     try {
                         TransactionUtil.commit(beganTx);
                     } catch (GenericTransactionException e) {