You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ofbiz.apache.org by jl...@apache.org on 2017/03/21 12:21:59 UTC
svn commit: r1787950 - in /ofbiz/branches/release16.11: ./
applications/content/src/main/java/org/apache/ofbiz/content/content/
applications/order/src/main/java/org/apache/ofbiz/order/order/
applications/order/src/main/java/org/apache/ofbiz/order/shopp...
Author: jleroux
Date: Tue Mar 21 12:21:59 2017
New Revision: 1787950
URL: http://svn.apache.org/viewvc?rev=1787950&view=rev
Log:
"Applied fix from trunk framework for revision: 1787949"
------------------------------------------------------------------------
r1787949 | jleroux | 2017-03-21 13:20:55 +0100 (mar. 21 mars 2017) | 2 lignes
No functional changes, replace finally blocks closing EntityListIterator by
try-with-resource, and refactors around
------------------------------------------------------------------------
Modified:
ofbiz/branches/release16.11/ (props changed)
ofbiz/branches/release16.11/applications/content/src/main/java/org/apache/ofbiz/content/content/ContentSearch.java
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
ofbiz/branches/release16.11/applications/product/src/main/java/org/apache/ofbiz/product/product/ProductSearchSession.java
ofbiz/branches/release16.11/applications/product/src/main/java/org/apache/ofbiz/shipment/shipment/ShipmentServices.java
ofbiz/branches/release16.11/framework/entity/src/main/java/org/apache/ofbiz/entity/GenericDelegator.java
ofbiz/branches/release16.11/framework/entityext/src/main/java/org/apache/ofbiz/entityext/data/EntityDataServices.java
Propchange: ofbiz/branches/release16.11/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Tue Mar 21 12:21:59 2017
@@ -10,5 +10,5 @@
/ofbiz/branches/json-integration-refactoring:1634077-1635900
/ofbiz/branches/multitenant20100310:921280-927264
/ofbiz/branches/release13.07:1547657
-/ofbiz/ofbiz-framework/trunk:1783202,1783388,1784549,1784558,1784708,1785882,1785925,1786079,1786214,1786525,1787047,1787133,1787176,1787535,1787906-1787911
+/ofbiz/ofbiz-framework/trunk:1783202,1783388,1784549,1784558,1784708,1785882,1785925,1786079,1786214,1786525,1787047,1787133,1787176,1787535,1787906-1787911,1787949
/ofbiz/trunk:1770481,1770490,1770540,1771440,1771448,1771516,1771935,1772346,1772880,1774772,1775441,1779724,1780659,1781109,1781125,1781979,1782498,1782520
Modified: ofbiz/branches/release16.11/applications/content/src/main/java/org/apache/ofbiz/content/content/ContentSearch.java
URL: http://svn.apache.org/viewvc/ofbiz/branches/release16.11/applications/content/src/main/java/org/apache/ofbiz/content/content/ContentSearch.java?rev=1787950&r1=1787949&r2=1787950&view=diff
==============================================================================
--- ofbiz/branches/release16.11/applications/content/src/main/java/org/apache/ofbiz/content/content/ContentSearch.java (original)
+++ ofbiz/branches/release16.11/applications/content/src/main/java/org/apache/ofbiz/content/content/ContentSearch.java Tue Mar 21 12:21:59 2017
@@ -168,14 +168,11 @@ public class ContentSearch {
long startMillis = System.currentTimeMillis();
// do the query
- EntityListIterator eli = this.doQuery(delegator);
- ArrayList<String> contentIds = this.makeContentIdList(eli);
- if (eli != null) {
- try {
- eli.close();
- } catch (GenericEntityException e) {
- Debug.logError(e, "Error closing ContentSearch EntityListIterator");
- }
+ ArrayList<String> contentIds = null;
+ try (EntityListIterator eli = this.doQuery(delegator)) {
+ contentIds = this.makeContentIdList(eli);
+ } catch (GenericEntityException e) {
+ Debug.logError(e, "Error closing ContentSearch EntityListIterator");
}
long endMillis = System.currentTimeMillis();
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=1787950&r1=1787949&r2=1787950&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 Tue Mar 21 12:21:59 2017
@@ -1503,43 +1503,36 @@ public class OrderServices {
cond = EntityCondition.makeCondition(exprs, EntityOperator.OR);
}
- EntityListIterator eli = null;
- try {
- eli = EntityQuery.use(delegator).select("orderId").from("OrderHeader").where(cond).queryIterator();
- } catch (GenericEntityException e) {
- Debug.logError(e, module);
- return ServiceUtil.returnError(e.getMessage());
- }
-
- if (eli != null) {
- // reset each order
- GenericValue orderHeader = null;
- while ((orderHeader = eli.next()) != null) {
- String orderId = orderHeader.getString("orderId");
- Map<String, Object> resetResult = null;
- try {
- resetResult = dispatcher.runSync("resetGrandTotal", UtilMisc.<String, Object>toMap("orderId", orderId, "userLogin", userLogin));
- } catch (GenericServiceException e) {
- Debug.logError(e, "ERROR: Cannot reset order totals - " + orderId, module);
- }
-
- if (resetResult != null && ServiceUtil.isError(resetResult)) {
- Debug.logWarning(UtilProperties.getMessage(resource_error,
- "OrderErrorCannotResetOrderTotals",
- UtilMisc.toMap("orderId",orderId,"resetResult",ServiceUtil.getErrorMessage(resetResult)), locale), module);
- }
- }
+ try (EntityListIterator eli = EntityQuery.use(delegator)
+ .select("orderId")
+ .from("OrderHeader")
+ .where(cond)
+ .queryIterator()) {
+
+ if (eli != null) {
+ // reset each order
+ GenericValue orderHeader = null;
+ while ((orderHeader = eli.next()) != null) {
+ String orderId = orderHeader.getString("orderId");
+ Map<String, Object> resetResult = null;
+ try {
+ resetResult = dispatcher.runSync("resetGrandTotal", UtilMisc.<String, Object>toMap("orderId", orderId, "userLogin", userLogin));
+ } catch (GenericServiceException e) {
+ Debug.logError(e, "ERROR: Cannot reset order totals - " + orderId, module);
+ }
- // close the ELI
- try {
- eli.close();
- } catch (GenericEntityException e) {
- Debug.logError(e, module);
+ if (resetResult != null && ServiceUtil.isError(resetResult)) {
+ Debug.logWarning(UtilProperties.getMessage(resource_error,
+ "OrderErrorCannotResetOrderTotals",
+ UtilMisc.toMap("orderId",orderId,"resetResult",ServiceUtil.getErrorMessage(resetResult)), locale), module);
+ } else {
+ Debug.logInfo("No orders found for reset processing", module);
+ }
+ }
}
- } else {
- Debug.logInfo("No orders found for reset processing", module);
+ } catch (GenericEntityException e) {
+ Debug.logError(e, module);
}
-
return ServiceUtil.returnSuccess();
}
@@ -1955,7 +1948,7 @@ public class OrderServices {
}
}
} catch (GenericEntityException e) {
- String errMsg = UtilProperties.getMessage(resource_error, "OrderDatabaseErrorCheckingIfWeShouldChangeOrderHeaderStatusToApproved", UtilMisc.toMap("errorString", e.toString()), locale);
+ String errMsg = UtilProperties.getMessage(resource_error, "OrderDatabaseErrorCheckingIfWeShouldChangeOrderHeaderStatusToApproved", UtilMisc.toMap("errorString", e.toString()), locale);
Debug.logError(e, errMsg, module);
return ServiceUtil.returnError(errMsg);
}
@@ -2014,11 +2007,11 @@ public class OrderServices {
Map<String, String> itemCommentMap = UtilGenerics.checkMap(context.get("itemCommentMap"));
Map<String, String> itemQuantityMap = UtilGenerics.checkMap(context.get("itemQtyMap"));
if ((cancelQuantity == null) && UtilValidate.isNotEmpty(itemQuantityMap)) {
- String key = orderItemSeqId+":"+shipGroupSeqId;
- if (UtilValidate.isNotEmpty(itemQuantityMap.get(key))) {
- cancelQuantity = new BigDecimal(itemQuantityMap.get(key));
- }
-
+ String key = orderItemSeqId+":"+shipGroupSeqId;
+ if (UtilValidate.isNotEmpty(itemQuantityMap.get(key))) {
+ cancelQuantity = new BigDecimal(itemQuantityMap.get(key));
+ }
+
}
// debugging message info
String itemMsgInfo = orderId + " / " + orderItemSeqId + " / " + shipGroupSeqId;
@@ -2119,7 +2112,7 @@ public class OrderServices {
"orderItemSeqId", orderItem.getString("orderItemSeqId"),
"shipGroupSeqId", orderItemShipGroupAssoc.getString("shipGroupSeqId"));
if (availableQuantity.compareTo(thisCancelQty) == 0) {
- try {
+ try {
dispatcher.runSync("deleteOrderItemShipGroupAssoc", localCtx);
} catch (GenericServiceException e) {
Debug.logError(e, module);
@@ -5569,15 +5562,15 @@ public class OrderServices {
Map<String, Object> result = null;
boolean beganTransaction = false;
- try {
+ 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 (EntityListIterator eli = EntityQuery.use(delegator)
+ .from("Subscription")
+ .where(exprs)
+ .queryIterator()) {
+
beganTransaction = TransactionUtil.begin();
-
- 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));
- EntityListIterator eli = null;
- eli = EntityQuery.use(delegator).from("Subscription").where(exprs).queryIterator();
-
if (eli != null) {
GenericValue subscription;
while (((subscription = eli.next()) != null)) {
@@ -5655,7 +5648,6 @@ public class OrderServices {
count++;
}
}
- eli.close();
}
} catch (GenericServiceException e) {
@@ -6203,17 +6195,17 @@ public class OrderServices {
@Override
public List<String> call() throws Exception {
List<String> orderIds = new LinkedList<String>();
- EntityListIterator eli = null;
- try {
- eli = EntityQuery.use(delegator).select("orderId").from("OrderHeader").where(cond).orderBy("entryDate ASC").queryIterator();
+ try (EntityListIterator eli = EntityQuery.use(delegator)
+ .select("orderId")
+ .from("OrderHeader")
+ .where(cond)
+ .orderBy("entryDate ASC")
+ .queryIterator()){
+
GenericValue orderHeader;
while ((orderHeader = eli.next()) != null) {
orderIds.add(orderHeader.getString("orderId"));
}
- } finally {
- if (eli != null) {
- eli.close();
- }
}
return orderIds;
}
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=1787950&r1=1787949&r2=1787950&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 Tue Mar 21 12:21:59 2017
@@ -125,12 +125,13 @@ public class ShoppingListServices {
Locale locale = (Locale) context.get("locale");
boolean beganTransaction = false;
- try {
- beganTransaction = TransactionUtil.begin();
-
- EntityListIterator eli = null;
- eli = EntityQuery.use(delegator).from("ShoppingList").where("shoppingListTypeId", "SLT_AUTO_REODR", "isActive", "Y").orderBy("-lastOrderedDate").queryIterator();
+ 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)) {
@@ -197,8 +198,6 @@ public class ShoppingListServices {
recurrence.incrementCurrentCount();
}
}
-
- eli.close();
}
return ServiceUtil.returnSuccess();
Modified: ofbiz/branches/release16.11/applications/product/src/main/java/org/apache/ofbiz/product/product/ProductSearchSession.java
URL: http://svn.apache.org/viewvc/ofbiz/branches/release16.11/applications/product/src/main/java/org/apache/ofbiz/product/product/ProductSearchSession.java?rev=1787950&r1=1787949&r2=1787950&view=diff
==============================================================================
--- ofbiz/branches/release16.11/applications/product/src/main/java/org/apache/ofbiz/product/product/ProductSearchSession.java (original)
+++ ofbiz/branches/release16.11/applications/product/src/main/java/org/apache/ofbiz/product/product/ProductSearchSession.java Tue Mar 21 12:21:59 2017
@@ -1229,33 +1229,26 @@ public class ProductSearchSession {
dynamicViewEntity.addViewLink("PFAC", "PFC", Boolean.FALSE, ModelKeyMap.makeKeyMapList("productFeatureId"));
entityConditionList.add(EntityCondition.makeCondition("pfcProductFeatureTypeId", EntityOperator.EQUALS, productFeatureTypeId));
- EntityListIterator eli = null;
- try {
- eli = EntityQuery.use(delegator)
+ List<Map<String, String>> featureCountList = null;
+ try (EntityListIterator eli = EntityQuery.use(delegator)
.select(UtilMisc.toSet("pfacProductFeatureId", "featureCount", "pfcDescription", "pfcProductFeatureTypeId"))
.from(dynamicViewEntity)
.where(entityConditionList)
.orderBy(productSearchContext.orderByList)
.cursorScrollInsensitive()
- .queryIterator();
+ .queryIterator()) {
+
+ featureCountList = new LinkedList<Map<String,String>>();
+ GenericValue searchResult = null;
+ while ((searchResult = eli.next()) != null) {
+ featureCountList.add(UtilMisc.<String, String>toMap("productFeatureId", (String) searchResult.get("pfacProductFeatureId"), "productFeatureTypeId", (String) searchResult.get("pfcProductFeatureTypeId"), "description", (String) searchResult.get("pfcDescription"), "featureCount", Long.toString((Long) searchResult.get("featureCount"))));
+ }
} catch (GenericEntityException e) {
Debug.logError(e, "Error in product search", module);
return null;
}
- List<Map<String, String>> featureCountList = new LinkedList<Map<String,String>>();
- GenericValue searchResult = null;
- while ((searchResult = eli.next()) != null) {
- featureCountList.add(UtilMisc.<String, String>toMap("productFeatureId", (String) searchResult.get("pfacProductFeatureId"), "productFeatureTypeId", (String) searchResult.get("pfcProductFeatureTypeId"), "description", (String) searchResult.get("pfcDescription"), "featureCount", Long.toString((Long) searchResult.get("featureCount"))));
- }
- if (eli != null) {
- try {
- eli.close();
- } catch (GenericEntityException e) {
- Debug.logError(e, "Error closing ProductSearch EntityListIterator");
- }
- }
return featureCountList;
}
@@ -1308,31 +1301,21 @@ public class ProductSearchSession {
entityConditionList.add(EntityCondition.makeCondition("ppcPrice", EntityOperator.LESS_THAN_EQUAL_TO, priceHigh));
entityConditionList.add(EntityCondition.makeCondition("ppcProductPriceTypeId", EntityOperator.EQUALS, "LIST_PRICE"));
- EntityListIterator eli = null;
- try {
- eli = EntityQuery.use(delegator).select(UtilMisc.toSet(fieldsToSelect))
- .from(dynamicViewEntity)
- .where(entityConditionList)
- .orderBy(productSearchContext.orderByList)
- .cursorScrollInsensitive()
- .queryIterator();
- } catch (GenericEntityException e) {
- Debug.logError(e, "Error in product search", module);
- return 0;
- }
-
- GenericValue searchResult = null;
Long priceRangeCount = Long.valueOf(0);
- while ((searchResult = eli.next()) != null) {
- priceRangeCount = searchResult.getLong("priceRangeCount");
- }
-
- if (eli != null) {
- try {
- eli.close();
- } catch (GenericEntityException e) {
- Debug.logError(e, "Error closing ProductSearch EntityListIterator");
+ try (EntityListIterator eli = EntityQuery.use(delegator)
+ .select(UtilMisc.toSet(fieldsToSelect))
+ .from(dynamicViewEntity)
+ .where(entityConditionList)
+ .orderBy(productSearchContext.orderByList)
+ .cursorScrollInsensitive()
+ .queryIterator()) {
+
+ GenericValue searchResult = null;
+ while ((searchResult = eli.next()) != null) {
+ priceRangeCount = searchResult.getLong("priceRangeCount");
}
+ } catch (GenericEntityException e) {
+ Debug.logError(e, "Error in product search", module);
}
return priceRangeCount;
}
@@ -1374,31 +1357,21 @@ public class ProductSearchSession {
ProductSearch.getAllSubCategoryIds(productCategoryId, productCategoryIdSet, delegator, productSearchContext.nowTimestamp);
entityConditionList.add(EntityCondition.makeCondition("pcmcProductCategoryId", EntityOperator.IN, productCategoryIdSet));
- EntityListIterator eli = null;
- try {
- eli = EntityQuery.use(delegator).select(UtilMisc.toSet(fieldsToSelect))
- .from(dynamicViewEntity)
- .where(entityConditionList)
- .orderBy(productSearchContext.orderByList)
- .cursorScrollInsensitive()
- .queryIterator();
- } catch (GenericEntityException e) {
- Debug.logError(e, "Error in product search", module);
- return 0;
- }
-
- GenericValue searchResult = null;
Long categoryCount = Long.valueOf(0);
- while ((searchResult = eli.next()) != null) {
- categoryCount = searchResult.getLong("categoryCount");
- }
-
- if (eli != null) {
- try {
- eli.close();
- } catch (GenericEntityException e) {
- Debug.logError(e, "Error closing ProductSearch EntityListIterator");
+ try (EntityListIterator eli = EntityQuery.use(delegator)
+ .select(UtilMisc.toSet(fieldsToSelect))
+ .from(dynamicViewEntity)
+ .where(entityConditionList)
+ .orderBy(productSearchContext.orderByList)
+ .cursorScrollInsensitive()
+ .queryIterator()) {
+
+ GenericValue searchResult = null;
+ while ((searchResult = eli.next()) != null) {
+ categoryCount = searchResult.getLong("categoryCount");
}
+ } catch (GenericEntityException e) {
+ Debug.logError(e, "Error in product search", module);
}
return categoryCount;
}
Modified: ofbiz/branches/release16.11/applications/product/src/main/java/org/apache/ofbiz/shipment/shipment/ShipmentServices.java
URL: http://svn.apache.org/viewvc/ofbiz/branches/release16.11/applications/product/src/main/java/org/apache/ofbiz/shipment/shipment/ShipmentServices.java?rev=1787950&r1=1787949&r2=1787950&view=diff
==============================================================================
--- ofbiz/branches/release16.11/applications/product/src/main/java/org/apache/ofbiz/shipment/shipment/ShipmentServices.java (original)
+++ ofbiz/branches/release16.11/applications/product/src/main/java/org/apache/ofbiz/shipment/shipment/ShipmentServices.java Tue Mar 21 12:21:59 2017
@@ -670,9 +670,11 @@ public class ShipmentServices {
Locale locale = (Locale) context.get("locale");
Map<String, String> shipmentMap = new HashMap<String, String>();
- EntityListIterator eli = null;
- try {
- eli = EntityQuery.use(delegator).from("OdbcPackageIn").orderBy("shipmentId", "shipmentPackageSeqId", "voidIndicator").queryIterator();
+ try (EntityListIterator eli = EntityQuery.use(delegator)
+ .from("OdbcPackageIn")
+ .orderBy("shipmentId", "shipmentPackageSeqId", "voidIndicator")
+ .queryIterator()) {
+
GenericValue pkgInfo;
while ((pkgInfo = eli.next()) != null) {
String packageSeqId = pkgInfo.getString("shipmentPackageSeqId");
@@ -779,14 +781,6 @@ public class ShipmentServices {
} catch (GenericEntityException e) {
Debug.logError(e, module);
return ServiceUtil.returnError(e.getMessage());
- } finally {
- if (eli != null) {
- try {
- eli.close();
- } catch (GenericEntityException e) {
- Debug.logError(e, module);
- }
- }
}
// update the status of each shipment
Modified: ofbiz/branches/release16.11/framework/entity/src/main/java/org/apache/ofbiz/entity/GenericDelegator.java
URL: http://svn.apache.org/viewvc/ofbiz/branches/release16.11/framework/entity/src/main/java/org/apache/ofbiz/entity/GenericDelegator.java?rev=1787950&r1=1787949&r2=1787950&view=diff
==============================================================================
--- ofbiz/branches/release16.11/framework/entity/src/main/java/org/apache/ofbiz/entity/GenericDelegator.java (original)
+++ ofbiz/branches/release16.11/framework/entity/src/main/java/org/apache/ofbiz/entity/GenericDelegator.java Tue Mar 21 12:21:59 2017
@@ -1581,17 +1581,9 @@ public class GenericDelegator implements
beganTransaction = TransactionUtil.begin();
}
- EntityListIterator eli = null;
List<GenericValue> list = null;
- try {
- eli = this.find(entityName, entityCondition, null, fieldsToSelect, orderBy, findOptions);
+ try (EntityListIterator eli = this.find(entityName, entityCondition, null, fieldsToSelect, orderBy, findOptions)) {
list = eli.getCompleteList();
- } finally {
- if (eli != null) {
- try {
- eli.close();
- } catch (Exception exc) {}
- }
}
if (useCache) {
Modified: ofbiz/branches/release16.11/framework/entityext/src/main/java/org/apache/ofbiz/entityext/data/EntityDataServices.java
URL: http://svn.apache.org/viewvc/ofbiz/branches/release16.11/framework/entityext/src/main/java/org/apache/ofbiz/entityext/data/EntityDataServices.java?rev=1787950&r1=1787949&r2=1787950&view=diff
==============================================================================
--- ofbiz/branches/release16.11/framework/entityext/src/main/java/org/apache/ofbiz/entityext/data/EntityDataServices.java (original)
+++ ofbiz/branches/release16.11/framework/entityext/src/main/java/org/apache/ofbiz/entityext/data/EntityDataServices.java Tue Mar 21 12:21:59 2017
@@ -32,7 +32,6 @@ import java.util.Locale;
import java.util.Map;
import org.apache.commons.codec.binary.Base64;
-import org.apache.shiro.crypto.AesCipherService;
import org.apache.ofbiz.base.crypto.DesCrypt;
import org.apache.ofbiz.base.util.Debug;
import org.apache.ofbiz.base.util.FileUtil;
@@ -55,6 +54,7 @@ import org.apache.ofbiz.service.Dispatch
import org.apache.ofbiz.service.GenericServiceException;
import org.apache.ofbiz.service.LocalDispatcher;
import org.apache.ofbiz.service.ServiceUtil;
+import org.apache.shiro.crypto.AesCipherService;
/**
* Entity Data Import/Export Services
@@ -422,9 +422,10 @@ public class EntityDataServices {
String entityName = (String) context.get("entityName");
String fieldName = (String) context.get("fieldName");
Locale locale = (Locale) context.get("locale");
- EntityListIterator eli = null;
- try {
- eli = EntityQuery.use(delegator).from(entityName).queryIterator();
+ try (EntityListIterator eli = EntityQuery.use(delegator)
+ .from(entityName)
+ .queryIterator()) {
+
GenericValue currentValue;
while ((currentValue = eli.next()) != null) {
byte[] bytes = currentValue.getBytes(fieldName);
@@ -436,15 +437,6 @@ public class EntityDataServices {
} catch (GenericEntityException e) {
Debug.logError(e, "Error unwrapping ByteWrapper records: " + e.toString(), module);
return ServiceUtil.returnError(UtilProperties.getMessage(resource, "EntityExtErrorUnwrappingRecords", UtilMisc.toMap("errorString", e.toString()), locale));
- } finally {
- if (eli != null) {
- try {
- eli.close();
- } catch (GenericEntityException e) {
- String errMsg = "Error closing EntityListIterator: " + e.toString();
- Debug.logError(e, errMsg, module);
- }
- }
}
return ServiceUtil.returnSuccess();