Spring 5.1.7 application with enabled SecurityManager on Java 11 wont start #23261
Labels
in: core
Issues in core modules (aop, beans, core, context, expression)
status: declined
A suggestion or change that we don't feel we should currently apply
When using the Spring 5.1.7 application with enabled Java SecurityManager on Java 11, the application wont start - on Java 8 everything works.
The problem is how class ZipFile changed from 8 to 11. When loading class resource from jar file and using security manager, JDK checks the jar LOC header.
On Java 8 this information is stored as boolean field directly on ZipFile class, but on 11 this field has moved to the inner static class
Source
of another inner static classCleanableResource
.Now for some reason, when Spring looks for a jar resource via class
PathMatchingResourcePatternResolver
and methoddoFindPathMatchingJarResources
it closes that jar in finally block, which dereferences the zsrc (Source
) field on CleanableResource - https://github.com/openjdk/jdk/blob/3c214ff134e5b8b922eaf695a2a113c829ef74a1/src/java.base/share/classes/java/util/zip/ZipFile.java#L800Afterwards, when JDK is checking for LOC header during class resource loading, the NPE is thrown, class is not loaded and the whole application crashes.
Im not really sure if this is even Spring bug, but would like to hear an opinion of a Spring developer.
The text was updated successfully, but these errors were encountered: