Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Fix InaccessibleObjectException from JPMS in ThreadLocal cleaner #25061

Merged
merged 1 commit into from
Jul 28, 2024

Conversation

OndroMih
Copy link
Contributor

Before it logged a warning and stacktrace if java.lang not open on JDK 17+. But this situation is expected. If it happens, the thread local checker is just not executed, because it cannot get info about ThreadLocals from the JVM. Logs only a simple warning, with instructions how to open the package and enable the checker.

Also sets the context (appName) of the WebApp CL to the name of the app file as a fallback.

Before, the log message looked like this:

org.glassfish.web.loader.ReferenceCleaner checkThreadLocalsForLeaks
WARNING: Failed to check for ThreadLocal references for web application [unknown]
java.lang.reflect.InaccessibleObjectException: Unable to make field java.lang.ThreadLocal$ThreadLocalMap java.lang.Thread.threadLocals accessible: module java.base does not "opens java.lang" to unnamed module @1cc50131
	at java.base/java.lang.reflect.AccessibleObject.throwInaccessibleObjectException(AccessibleObject.java:391)
	at java.base/java.lang.reflect.AccessibleObject.checkCanSetAccessible(AccessibleObject.java:367)
	at java.base/java.lang.reflect.AccessibleObject.checkCanSetAccessible(AccessibleObject.java:315)
	at java.base/java.lang.reflect.Field.checkCanSetAccessible(Field.java:183)
	at java.base/java.lang.reflect.Field.setAccessible(Field.java:177)
	at org.glassfish.web.loader.ReferenceCleaner.setAccessible(ReferenceCleaner.java:348)
	at org.glassfish.web.loader.ReferenceCleaner.checkThreadLocalsForLeaks(ReferenceCleaner.java:115)

Logged a warning and stacktrace if java.lang not open on JDK 17+. 
This is expected. Logs only a simple warning, with instructoins how to open the package.

Also sets the context (appName) of the WebApp CL to the name of the app file as a fallback.
@pzygielo pzygielo merged commit 546f175 into eclipse-ee4j:master Jul 28, 2024
2 checks passed
@pzygielo pzygielo added this to the 7.0.16 milestone Jul 28, 2024
@dmatej
Copy link
Contributor

dmatej commented Jul 29, 2024

I was too late :-)

@dmatej dmatej modified the milestones: 7.0.16, 7.0.17 Jul 29, 2024
@OndroMih OndroMih deleted the ondromih-jpms branch August 12, 2024 21:34
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants