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/22 13:27:04 UTC

svn commit: r1812915 - in /ofbiz/ofbiz-framework/trunk/framework/entity/src/main/java/org/apache/ofbiz/entity/transaction: GenericXaResource.java JNDITransactionFactory.java TransactionUtil.java

Author: mbrohl
Date: Sun Oct 22 13:27:03 2017
New Revision: 1812915

URL: http://svn.apache.org/viewvc?rev=1812915&view=rev
Log:
Improved: Fixing defects reported by FindBugs, package 
org.apache.ofbiz.entity.transaction.
(OFBIZ-9707)

Thanks Julian Leichert for reporting and providing the patch.

Modified:
    ofbiz/ofbiz-framework/trunk/framework/entity/src/main/java/org/apache/ofbiz/entity/transaction/GenericXaResource.java
    ofbiz/ofbiz-framework/trunk/framework/entity/src/main/java/org/apache/ofbiz/entity/transaction/JNDITransactionFactory.java
    ofbiz/ofbiz-framework/trunk/framework/entity/src/main/java/org/apache/ofbiz/entity/transaction/TransactionUtil.java

Modified: ofbiz/ofbiz-framework/trunk/framework/entity/src/main/java/org/apache/ofbiz/entity/transaction/GenericXaResource.java
URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/framework/entity/src/main/java/org/apache/ofbiz/entity/transaction/GenericXaResource.java?rev=1812915&r1=1812914&r2=1812915&view=diff
==============================================================================
--- ofbiz/ofbiz-framework/trunk/framework/entity/src/main/java/org/apache/ofbiz/entity/transaction/GenericXaResource.java (original)
+++ ofbiz/ofbiz-framework/trunk/framework/entity/src/main/java/org/apache/ofbiz/entity/transaction/GenericXaResource.java Sun Oct 22 13:27:03 2017
@@ -207,7 +207,7 @@ public abstract class GenericXaResource
         try {
             if (timeout != null) {
                 // sleep until the transaction times out
-                sleep(timeout.intValue() * 1000);
+                sleep(timeout.intValue() * 1000L);
 
                 if (active) {
                     // get the current status

Modified: ofbiz/ofbiz-framework/trunk/framework/entity/src/main/java/org/apache/ofbiz/entity/transaction/JNDITransactionFactory.java
URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/framework/entity/src/main/java/org/apache/ofbiz/entity/transaction/JNDITransactionFactory.java?rev=1812915&r1=1812914&r2=1812915&view=diff
==============================================================================
--- ofbiz/ofbiz-framework/trunk/framework/entity/src/main/java/org/apache/ofbiz/entity/transaction/JNDITransactionFactory.java (original)
+++ ofbiz/ofbiz-framework/trunk/framework/entity/src/main/java/org/apache/ofbiz/entity/transaction/JNDITransactionFactory.java Sun Oct 22 13:27:03 2017
@@ -51,11 +51,11 @@ public class JNDITransactionFactory impl
     // Debug module name
     public static final String module = JNDITransactionFactory.class.getName();
 
-    static TransactionManager transactionManager = null;
-    static UserTransaction userTransaction = null;
+    volatile TransactionManager transactionManager = null;
+    volatile UserTransaction userTransaction = null;
 
     // protected static UtilCache dsCache = new UtilCache("entity.JndiDataSources", 0, 0);
-    protected static ConcurrentHashMap<String, DataSource> dsCache = new ConcurrentHashMap<String, DataSource>();
+    protected static final ConcurrentHashMap<String, DataSource> dsCache = new ConcurrentHashMap<String, DataSource>();
 
     public TransactionManager getTransactionManager() {
         if (transactionManager == null) {

Modified: ofbiz/ofbiz-framework/trunk/framework/entity/src/main/java/org/apache/ofbiz/entity/transaction/TransactionUtil.java
URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/framework/entity/src/main/java/org/apache/ofbiz/entity/transaction/TransactionUtil.java?rev=1812915&r1=1812914&r2=1812915&view=diff
==============================================================================
--- ofbiz/ofbiz-framework/trunk/framework/entity/src/main/java/org/apache/ofbiz/entity/transaction/TransactionUtil.java (original)
+++ ofbiz/ofbiz-framework/trunk/framework/entity/src/main/java/org/apache/ofbiz/entity/transaction/TransactionUtil.java Sun Oct 22 13:27:03 2017
@@ -74,7 +74,7 @@ public final class TransactionUtil imple
     private static ThreadLocal<Timestamp> transactionLastNowStamp = new ThreadLocal<Timestamp>();
 
     private static final boolean debugResources = readDebugResources();
-    public static Map<Xid, DebugXaResource> debugResMap = Collections.<Xid, DebugXaResource>synchronizedMap(new HashMap<Xid, DebugXaResource>());
+    public static final Map<Xid, DebugXaResource> debugResMap = Collections.<Xid, DebugXaResource>synchronizedMap(new HashMap<Xid, DebugXaResource>());
     // in order to improve performance allThreadsTransactionBeginStack and allThreadsTransactionBeginStackSave are only maintained when logging level INFO is on
     private static Map<Long, Exception> allThreadsTransactionBeginStack = Collections.<Long, Exception>synchronizedMap(new HashMap<Long, Exception>());
     private static Map<Long, List<Exception>> allThreadsTransactionBeginStackSave = Collections.<Long, List<Exception>>synchronizedMap(new HashMap<Long, List<Exception>>());
@@ -854,7 +854,7 @@ public final class TransactionUtil imple
     private static ThreadLocal<Map<Transaction, Timestamp>> suspendedTxStartStamps = new ThreadLocal<Map<Transaction, Timestamp>>() {
         @Override
         public Map<Transaction, Timestamp> initialValue() {
-            return UtilGenerics.checkMap(new ListOrderedMap());
+            return UtilGenerics.checkMap(new ListOrderedMap<>());
         }
     };