Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

JDK 24: WARNING: sun.misc.Unsafe::invokeCleaner has been called by org.apache.tomcat.util.buf.ByteBufferUtils #44042

Open
transentia opened this issue Jan 31, 2025 · 3 comments
Labels
status: waiting-for-feedback We need additional information before we can continue status: waiting-for-triage An issue we've not yet triaged

Comments

@transentia
Copy link

transentia commented Jan 31, 2025

Windows 11
openjdk-24-ea+34_windows-x64_bin
Spring boot: 3.4.2
Apache Tomcat/10.1.34

Gets WARNING at startup:

C:\LocalData\DEV\Java\jdk-24\bin\java.exe --enable-preview --enable-native-access=ALL-UNNAMED -XX:TieredStopAtLevel=1 ...

19:42:21.172  INFO - tools.ToolsApplication                   : Starting ToolsApplication using Java 24-ea with PID 19000 (...)
...
19:42:22.188  INFO - o.s.b.w.embedded.tomcat.TomcatWebServer  : Tomcat initialized with port 8080 (https)
19:42:22.198  INFO - o.apache.catalina.core.StandardService   : Starting service [Tomcat]
19:42:22.198  INFO - o.apache.catalina.core.StandardEngine    : Starting Servlet engine: [Apache Tomcat/10.1.34]
...
19:42:23.171  INFO - o.s.b.w.embedded.tomcat.TomcatWebServer  : Tomcat started on port 8080 (https) with context path '/'
19:42:23.177  INFO - tools.ToolsApplication                   : Started ToolsApplication in 2.428 seconds (process running for 2.821)
WARNING: A terminally deprecated method in sun.misc.Unsafe has been called
WARNING: sun.misc.Unsafe::invokeCleaner has been called by org.apache.tomcat.util.buf.ByteBufferUtils (file:/E:/.gradle/caches/modules-2/files-2.1/org.apache.tomcat.embed/tomcat-embed-core/10.1.34/f610f84be607fbc82e393cc220f0ad45f92afc91/tomcat-embed-core-10.1.34.jar)
WARNING: Please consider reporting this to the maintainers of class org.apache.tomcat.util.buf.ByteBufferUtils
WARNING: sun.misc.Unsafe::invokeCleaner will be removed in a future release

Havent' seen this reported anywhere else (searching here did not find anything).

I raised this in Apache Bugzilla as well: https://bz.apache.org/bugzilla/show_bug.cgi?id=69559

They didn't seem too interested...

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Jan 31, 2025
@philwebb
Copy link
Member

philwebb commented Feb 1, 2025

We also have #44033 tracking a similar issue.

Running our SampleTomcatApplication, I don't see any calls to Unsafe.invokeCleaner when debugging the application. @transentia, is there anything unusual about your application configuration? Can you provide a sample that reproduces the warning?

@philwebb philwebb added the status: waiting-for-feedback We need additional information before we can continue label Feb 1, 2025
@wilkinsona
Copy link
Member

I think the use of SSL might be key here. Using the JVM argument --sun-misc-unsafe-memory-access=debug to get a stack trace when invokeCleaner is called, the following is logged when a request that uses HTTPS is received:

WARNING: sun.misc.Unsafe::invokeCleaner called by org.apache.tomcat.util.buf.ByteBufferUtils (file:/Users/aw036093/.gradle/caches/modules-2/files-2.1/org.apache.tomcat.embed/tomcat-embed-core/10.1.34/f610f84be607fbc82e393cc220f0ad45f92afc91/tomcat-embed-core-10.1.34.jar)
	at org.apache.tomcat.util.buf.ByteBufferUtils.<clinit>(ByteBufferUtils.java:46)
	at org.apache.tomcat.util.net.SocketBufferHandler.expand(SocketBufferHandler.java:222)
	at org.apache.tomcat.util.net.SecureNioChannel.processSNI(SecureNioChannel.java:319)
	at org.apache.tomcat.util.net.SecureNioChannel.handshake(SecureNioChannel.java:154)
	at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1716)
	at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:52)
	at org.apache.tomcat.util.threads.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1190)
	at org.apache.tomcat.util.threads.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:659)
	at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:63)
	at java.base/java.lang.Thread.run(Thread.java:1447)

As far as I can tell, there's no configuration option that would allow us to use SSL but not go down this code path. What have I missed please, @markt-asf?

@wilkinsona
Copy link
Member

There's a similar problem when using HTTP/2:

WARNING: sun.misc.Unsafe::invokeCleaner called by org.apache.tomcat.util.buf.ByteBufferUtils (file:/Users/aw036093/.gradle/caches/modules-2/files-2.1/org.apache.tomcat.embed/tomcat-embed-core/10.1.34/f610f84be607fbc82e393cc220f0ad45f92afc91/tomcat-embed-core-10.1.34.jar)
	at org.apache.tomcat.util.buf.ByteBufferUtils.<clinit>(ByteBufferUtils.java:46)
	at org.apache.tomcat.util.net.SocketBufferHandler.expand(SocketBufferHandler.java:222)
	at org.apache.coyote.http2.Http2AsyncParser.<init>(Http2AsyncParser.java:44)
	at org.apache.coyote.http2.Http2AsyncUpgradeHandler.getParser(Http2AsyncUpgradeHandler.java:86)
	at org.apache.coyote.http2.Http2UpgradeHandler.init(Http2UpgradeHandler.java:206)
	at org.apache.coyote.http2.Http2AsyncUpgradeHandler.init(Http2AsyncUpgradeHandler.java:43)
	at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:947)
	at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1741)
	at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:52)
	at org.apache.tomcat.util.threads.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1190)
	at org.apache.tomcat.util.threads.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:659)
	at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:63)
	at java.base/java.lang.Thread.run(Thread.java:1447)

This was without SSL. With SSL, the earlier warning prevents the later warning as I believe use of invokeCleaner is only logged once.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: waiting-for-feedback We need additional information before we can continue status: waiting-for-triage An issue we've not yet triaged
Projects
None yet
Development

No branches or pull requests

4 participants