svn commit: r1798179 - in /ofbiz/branches/release16.11/applications/order/src/main/java/org/apache/ofbiz/order: order/OrderServices.java shoppinglist/ShoppingListServices.java

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

svn commit: r1798179 - in /ofbiz/branches/release16.11/applications/order/src/main/java/org/apache/ofbiz/order: order/OrderServices.java shoppinglist/ShoppingListServices.java

jleroux@apache.org
Author: jleroux
Date: Fri Jun  9 09:36:01 2017
New Revision: 1798179

URL: http://svn.apache.org/viewvc?rev=1798179&view=rev
Log:
Fixed: Use try-with-resources statement wherever it's possible
(OFBIZ-8202)

This fixes 2 bugs introduced with r1787949. I checked there are no other similar

Thanks: Daniel Coric for report on user ML

Modified:
    ofbiz/branches/release16.11/applications/order/src/main/java/org/apache/ofbiz/order/order/OrderServices.java
    ofbiz/branches/release16.11/applications/order/src/main/java/org/apache/ofbiz/order/shoppinglist/ShoppingListServices.java

Modified: ofbiz/branches/release16.11/applications/order/src/main/java/org/apache/ofbiz/order/order/OrderServices.java
URL: http://svn.apache.org/viewvc/ofbiz/branches/release16.11/applications/order/src/main/java/org/apache/ofbiz/order/order/OrderServices.java?rev=1798179&r1=1798178&r2=1798179&view=diff
==============================================================================
--- ofbiz/branches/release16.11/applications/order/src/main/java/org/apache/ofbiz/order/order/OrderServices.java (original)
+++ ofbiz/branches/release16.11/applications/order/src/main/java/org/apache/ofbiz/order/order/OrderServices.java Fri Jun  9 09:36:01 2017
@@ -5565,12 +5565,17 @@ public class OrderServices {
         List<EntityExpr> exprs = UtilMisc.toList(EntityCondition.makeCondition("automaticExtend", EntityOperator.EQUALS, "Y"),
                 EntityCondition.makeCondition("orderId", EntityOperator.NOT_EQUAL, null),
                 EntityCondition.makeCondition("productId", EntityOperator.NOT_EQUAL, null));
+        try {
+            beganTransaction = TransactionUtil.begin();
+        } catch (GenericTransactionException e1) {
+            Debug.logError(e1, "[Delegator] Could not begin transaction: " + e1.toString(), module);
+        }
+        
         try (EntityListIterator eli = EntityQuery.use(delegator)
                 .from("Subscription")
                 .where(exprs)
                 .queryIterator()) {
-            
-            beganTransaction = TransactionUtil.begin();
+
             if (eli != null) {
                 GenericValue subscription;
                 while (((subscription = eli.next()) != null)) {

Modified: ofbiz/branches/release16.11/applications/order/src/main/java/org/apache/ofbiz/order/shoppinglist/ShoppingListServices.java
URL: http://svn.apache.org/viewvc/ofbiz/branches/release16.11/applications/order/src/main/java/org/apache/ofbiz/order/shoppinglist/ShoppingListServices.java?rev=1798179&r1=1798178&r2=1798179&view=diff
==============================================================================
--- ofbiz/branches/release16.11/applications/order/src/main/java/org/apache/ofbiz/order/shoppinglist/ShoppingListServices.java (original)
+++ ofbiz/branches/release16.11/applications/order/src/main/java/org/apache/ofbiz/order/shoppinglist/ShoppingListServices.java Fri Jun  9 09:36:01 2017
@@ -35,6 +35,7 @@ import org.apache.ofbiz.base.util.UtilVa
 import org.apache.ofbiz.entity.Delegator;
 import org.apache.ofbiz.entity.GenericEntityException;
 import org.apache.ofbiz.entity.GenericValue;
+import org.apache.ofbiz.entity.transaction.GenericTransactionException;
 import org.apache.ofbiz.entity.transaction.TransactionUtil;
 import org.apache.ofbiz.entity.util.EntityListIterator;
 import org.apache.ofbiz.entity.util.EntityQuery;
@@ -125,13 +126,18 @@ public class ShoppingListServices {
         Locale locale = (Locale) context.get("locale");
 
         boolean beganTransaction = false;
+        try {
+            beganTransaction = TransactionUtil.begin();
+        } catch (GenericTransactionException e1) {
+            Debug.logError(e1, "[Delegator] Could not begin transaction: " + e1.toString(), module);
+        }
+        
         try (EntityListIterator eli = EntityQuery.use(delegator)
                 .from("ShoppingList")
                 .where("shoppingListTypeId", "SLT_AUTO_REODR", "isActive", "Y")
                 .orderBy("-lastOrderedDate")
                 .queryIterator()) {
 
-            beganTransaction = TransactionUtil.begin();
             if (eli != null) {
                 GenericValue shoppingList;
                 while (((shoppingList = eli.next()) != null)) {