Skip to content

Commit 7f04fc9

Browse files
committed
[bugfix] Previously modules of modules were reset with the wrong
context, this meant that not all resources stored in context variables were correctly cleaned up, therefore leaking resources and memory. In addition reset was previously called more than once for the same module which was unecessary. Closes #3889
1 parent d823487 commit 7f04fc9

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

exist-core/src/main/java/org/exist/xquery/XQueryContext.java

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,7 @@ public class XQueryContext implements BinaryValueManager, Context {
209209
protected XQueryWatchDog watchdog;
210210

211211
/**
212-
* Loaded modules.
212+
* Loaded modules within this module.
213213
*
214214
* The format of the map is: <code>Map&lt;NamespaceURI, Modules&gt;</code>.
215215
*/
@@ -1402,7 +1402,13 @@ public void reset(final boolean keepGlobals) {
14021402
watchdog.reset();
14031403
}
14041404

1405-
for (final Module[] modules : allModules.values()) {
1405+
/*
1406+
NOTE: we use `modules` (and not `allModules`) here so as to only reset
1407+
the modules of this module.
1408+
The inner call to `module.reset` will be called on sub-modules
1409+
which in-turn will reset their modules, and so on.
1410+
*/
1411+
for (final Module[] modules : modules.values()) {
14061412
for (final Module module : modules) {
14071413
module.reset(this, keepGlobals);
14081414
}

0 commit comments

Comments
 (0)