From e76e9c04de000cc7c06dcb350d825603d65d16e1 Mon Sep 17 00:00:00 2001 From: Jacques Le Roux Date: Thu, 1 Jun 2017 13:23:40 +0000 Subject: [PATCH] No functional changes. Replaces entityListIterator.close() in finally by try-with-ressource git-svn-id: https://svn.apache.org/repos/asf/ofbiz/ofbiz-framework/trunk@1797222 13f79535-47bb-0310-9956-ffa450edef68 --- .../communication/CommunicationEventServices.java | 11 +---------- .../apache/ofbiz/common/test/PerformFindTests.java | 11 +---------- 2 files changed, 2 insertions(+), 20 deletions(-) diff --git a/applications/party/src/main/java/org/apache/ofbiz/party/communication/CommunicationEventServices.java b/applications/party/src/main/java/org/apache/ofbiz/party/communication/CommunicationEventServices.java index 41d2fa6c3a..f35258c38d 100644 --- a/applications/party/src/main/java/org/apache/ofbiz/party/communication/CommunicationEventServices.java +++ b/applications/party/src/main/java/org/apache/ofbiz/party/communication/CommunicationEventServices.java @@ -1151,21 +1151,12 @@ public class CommunicationEventServices { inputFields.put("infoString_ic", caseInsensitiveEmail); result = dispatcher.runSync("performFind", UtilMisc.toMap("entityName", "WorkEffortContactMechView" ,"inputFields", inputFields, "userLogin", userLogin)); - EntityListIterator listIt = (EntityListIterator) result.get("listIt"); - - try { + try (EntityListIterator listIt = (EntityListIterator) result.get("listIt")) { List list = listIt.getCompleteList(); List filteredList = EntityUtil.filterByDate(list); tempResults.addAll(filteredList); } catch (GenericEntityException e) { Debug.logError(e, module); - } finally { - try { - listIt.close(); - } catch (GenericEntityException e) { - Debug.logError(e, module); - } - } } } } diff --git a/framework/common/src/main/java/org/apache/ofbiz/common/test/PerformFindTests.java b/framework/common/src/main/java/org/apache/ofbiz/common/test/PerformFindTests.java index bfac86aaa0..1704ad18ce 100644 --- a/framework/common/src/main/java/org/apache/ofbiz/common/test/PerformFindTests.java +++ b/framework/common/src/main/java/org/apache/ofbiz/common/test/PerformFindTests.java @@ -42,20 +42,11 @@ public class PerformFindTests extends OFBizTestCase { } private List getCompleteList(Map context) { - EntityListIterator listIt = (EntityListIterator) context.get("listIt"); List foundElements = new LinkedList(); - if (listIt != null) { - try { + try (EntityListIterator listIt = (EntityListIterator) context.get("listIt")) { foundElements = listIt.getCompleteList(); } catch (GenericEntityException e) { Debug.logError(" Failed to extract values from EntityListIterator after a performFind service", module); - } finally { - try { - listIt.close(); - } catch (GenericEntityException e) { - Debug.logError(" Failed to close EntityListIterator after a performFind service", module); - } - } } return foundElements; }