Skip to content

Recent caching additions in javax.naming will break code #2367

@galderz

Description

@galderz

JDK-8223260 has been recently been fixed in jdk 11. When using a JDK that includes this fix, code relying on javax.naming will encounter exceptions like this:

2020-04-17 15:21:30,378 ERROR [io.qua.ver.htt.run.QuarkusErrorHandler] (executor-thread-1) HTTP Request to /api/requiresStandardRole failed, error id: 4af2a4af-1daf-448c-8336-69ab4abec3c2-1: com.oracle.svm.core.jdk.UnsupportedFeatureError: JDK11OrLater: Target_java_lang_ClassLoader.createOrGetClassLoaderValueMap()
	at com.oracle.svm.core.util.VMError.unsupportedFeature(VMError.java:86)
	at java.lang.ClassLoader.createOrGetClassLoaderValueMap(ClassLoader.java:254)
	at java.lang.System$2.createOrGetClassLoaderValueMap(System.java:2125)
	at jdk.internal.loader.AbstractClassLoaderValue.map(AbstractClassLoaderValue.java:266)
	at jdk.internal.loader.AbstractClassLoaderValue.computeIfAbsent(AbstractClassLoaderValue.java:189)
	at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:711)
	at javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:305)
	at javax.naming.InitialContext.init(InitialContext.java:236)
	at javax.naming.ldap.InitialLdapContext.<init>(InitialLdapContext.java:154)

This is due to a cache introduced in the JDK.

I've found a workaround for Quarkus (see PR associated with quarkusio/quarkus#8651), but others are likely to encounter similar issues. So, we should probably have a general solution for all.

Unfortunately the caching code (see here) is embedded right into the getInitialContext method which makes does not make it easy to substitute for.

At first glance, I can't see a right substitution that could be made. I wonder if the prohibition of createOrGetClassLoaderValueMap is too harsh? What's the issue with it? Creating a CHM of ClassLoaders? Or the reflection call inside createOrGetClassLoaderValueMap?

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions