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

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

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

jleroux@apache.org
Author: jleroux
Date: Sun Aug 13 19:20:14 2017
New Revision: 1804940

URL: http://svn.apache.org/viewvc?rev=1804940&view=rev
Log:
Implemented: ServiceSemaphore: Check for Transaction before suspending it in
dbWrite(...)
(OFBIZ-9401)

In ServiceSemaphore.dbWrite(...) the transaction is suspended without checking
if there is a transaction in place. This results in logging a warning each time
the TransactionUtil.suspend() method is invoked without a current transaction in
 place. The given patch cuts this unnecessary logging by checking if there is an
 transaction in place to suspend. If a transaction exists - suspend it.

Thanks: Martin Becker

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=1804940&r1=1804939&r2=1804940&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 Sun Aug 13 19:20:14 2017
@@ -146,7 +146,9 @@ public class ServiceSemaphore {
 
         try {
             // prepare the suspended transaction
-            parent = TransactionUtil.suspend();
+            if (TransactionUtil.isTransactionInPlace()) {
+                parent = TransactionUtil.suspend();
+            }
             beganTx = TransactionUtil.begin();
             if (!beganTx) {
                 throw new SemaphoreFailException("Cannot obtain unique transaction for semaphore logging");