svn commit: r1797073 - /ofbiz/ofbiz-plugins/trunk/webpos/src/main/java/org/apache/ofbiz/webpos/search/WebPosSearch.java

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

svn commit: r1797073 - /ofbiz/ofbiz-plugins/trunk/webpos/src/main/java/org/apache/ofbiz/webpos/search/WebPosSearch.java

jleroux@apache.org
Author: jleroux
Date: Wed May 31 17:04:40 2017
New Revision: 1797073

URL: http://svn.apache.org/viewvc?rev=1797073&view=rev
Log:
Improved: EntityListIterator closed but not in case of exception
(OFBIZ-9385)

This is an improvement only because no cases were reported. But obviously in
case of unlucky exception after the EntityListIterator creation and before it's
closed the EntityListIterator remains in memory.
It should be closed in EntityListIterator.finalize() but the less happens there
the better.

The solution is to use try-with-ressources

Modified:
    ofbiz/ofbiz-plugins/trunk/webpos/src/main/java/org/apache/ofbiz/webpos/search/WebPosSearch.java

Modified: ofbiz/ofbiz-plugins/trunk/webpos/src/main/java/org/apache/ofbiz/webpos/search/WebPosSearch.java
URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-plugins/trunk/webpos/src/main/java/org/apache/ofbiz/webpos/search/WebPosSearch.java?rev=1797073&r1=1797072&r2=1797073&view=diff
==============================================================================
--- ofbiz/ofbiz-plugins/trunk/webpos/src/main/java/org/apache/ofbiz/webpos/search/WebPosSearch.java (original)
+++ ofbiz/ofbiz-plugins/trunk/webpos/src/main/java/org/apache/ofbiz/webpos/search/WebPosSearch.java Wed May 31 17:04:40 2017
@@ -171,10 +171,8 @@ public class WebPosSearch {
         }
         mainCond = EntityCondition.makeCondition(andExprs, EntityOperator.AND);
         List<GenericValue> parties = null;
-        try {
-            EntityListIterator pli = delegator.findListIteratorByCondition(dynamicView, mainCond, null, null, orderBy, null);
+        try (EntityListIterator pli = delegator.findListIteratorByCondition(dynamicView, mainCond, null, null, orderBy, null)) {
             parties = EntityUtil.filterByDate(pli.getCompleteList(), true);
-            pli.close();
         } catch (GenericEntityException e) {
             Debug.logError(e, module);
         }