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 2022/12/07 09:57:34 UTC
[ofbiz-framework] branch trunk updated: Reverts "Fixed: EntityListIterator closed but not in case of exception (OFBIZ-9385)"
This is an automated email from the ASF dual-hosted git repository.
jleroux pushed a commit to branch trunk
in repository https://gitbox.apache.org/repos/asf/ofbiz-framework.git
The following commit(s) were added to refs/heads/trunk by this push:
new 0e931d5ae4 Reverts "Fixed: EntityListIterator closed but not in case of exception (OFBIZ-9385)"
0e931d5ae4 is described below
commit 0e931d5ae4445c8e3a800d552ddacec2940941ba
Author: Jacques Le Roux <ja...@les7arts.com>
AuthorDate: Wed Dec 7 10:55:31 2022 +0100
Reverts "Fixed: EntityListIterator closed but not in case of exception (OFBIZ-9385)"
This reverts commit 688142c5d3fc72c36ffd585fa2b08a9ac3d62df4.
Not closing eli in handleOutput is not an option, nor using a try-with-ressource
for eli for the same reason
I put a comment in ListFinder to make things a bit more clear.
---
.../org/apache/ofbiz/entity/finder/EntityFinderUtil.java | 1 +
.../java/org/apache/ofbiz/entity/finder/ListFinder.java | 14 ++++++++++++--
2 files changed, 13 insertions(+), 2 deletions(-)
diff --git a/framework/entity/src/main/java/org/apache/ofbiz/entity/finder/EntityFinderUtil.java b/framework/entity/src/main/java/org/apache/ofbiz/entity/finder/EntityFinderUtil.java
index 79f7727b96..121ad09e1a 100644
--- a/framework/entity/src/main/java/org/apache/ofbiz/entity/finder/EntityFinderUtil.java
+++ b/framework/entity/src/main/java/org/apache/ofbiz/entity/finder/EntityFinderUtil.java
@@ -394,6 +394,7 @@ public final class EntityFinderUtil {
int size = getSize(context);
try {
listAcsr.put(context, eli.getPartialList(start, size));
+ eli.close();
} catch (GenericEntityException e) {
String errMsg = "Error getting partial list in limit-range with start=" + start + " and size=" + size + ": " + e.toString();
Debug.logError(e, errMsg, MODULE);
diff --git a/framework/entity/src/main/java/org/apache/ofbiz/entity/finder/ListFinder.java b/framework/entity/src/main/java/org/apache/ofbiz/entity/finder/ListFinder.java
index c9ea06705d..56b5c2da75 100644
--- a/framework/entity/src/main/java/org/apache/ofbiz/entity/finder/ListFinder.java
+++ b/framework/entity/src/main/java/org/apache/ofbiz/entity/finder/ListFinder.java
@@ -215,12 +215,22 @@ public abstract class ListFinder extends Finder {
options.setMaxRows(size * (index + 1));
}
boolean beganTransaction = false;
- try (EntityListIterator eli = delegator.find(entityName, whereEntityCondition, havingEntityCondition, fieldsToSelect, orderByFields,
- options)) {
+ try {
if (useTransaction) {
beganTransaction = TransactionUtil.begin();
}
+ EntityListIterator eli = delegator.find(entityName, whereEntityCondition, havingEntityCondition, fieldsToSelect, orderByFields,
+ options);
this.outputHandler.handleOutput(eli, context, listAcsr);
+ // NOTE: the eli EntityListIterator is closed by the line above, in outputHandler.handleOutput().
+ // It's necessary for cases like EntityAnd.getChildren() in ModelTree.java where eli is used.
+ // See OFBIZ-9385 for more details. Also using a try-with-ressource for eli is not an option for the same reason.
+ // I guess it's related to ModelTree "DEVELOPERS PLEASE READ" header
+ // It dates since http://svn.apache.org/viewvc?view=revision&revision=1652852
+ // EntityAnd::runAction and EntityCondition::runAction in ModelTreeAction.java use ListFinder::runFind we are in.
+ // It's also the case for EntityAnd::exec and EntityCondition::exec in Minilang
+ // I did not dig further...
+
} catch (GenericEntityException e) {
String errMsg = "Failure in by " + label + " find operation, rolling back transaction";
Debug.logError(e, errMsg, MODULE);