Skip to content

Commit b937290

Browse files
fix class loader closing, and postpone it until QueryResource.close has been called (#2564)
1 parent 3fca948 commit b937290

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

basex-core/src/main/java/org/basex/query/util/pkg/ModuleLoader.java

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -49,18 +49,20 @@ public ModuleLoader(final Context context) {
4949
* implementing {@link QueryResource}.
5050
*/
5151
public void close() {
52-
if(loader != LOADER) {
53-
try {
54-
((URLClassLoader) loader).close();
55-
} catch(final IOException ex) {
56-
Util.stack(ex);
57-
}
58-
}
5952
for(final Object jm : javaModules) {
6053
for(final Class<?> c : jm.getClass().getInterfaces()) {
6154
if(c == QueryResource.class) Reflect.invoke(CLOSE, jm);
6255
}
6356
}
57+
try {
58+
while(loader != LOADER) {
59+
final ClassLoader parent = loader.getParent();
60+
((URLClassLoader) loader).close();
61+
loader = parent;
62+
}
63+
} catch(final IOException ex) {
64+
Util.stack(ex);
65+
}
6466
}
6567

6668
/**

0 commit comments

Comments
 (0)