Improved: Use try-with-resources statement wherever it's possible

(OFBIZ-8202)

Replace finally blocks closing EntityListIterator by 
try-with-resource, and refactors around

git-svn-id: https://svn.apache.org/repos/asf/ofbiz/ofbiz-framework/trunk@1787949 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Jacques Le Roux
2017-03-21 12:20:55 +00:00
parent a8603796cd
commit 16f0d33d79
7 changed files with 106 additions and 167 deletions
@@ -1581,17 +1581,9 @@ public class GenericDelegator implements Delegator {
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) {