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

Jetty support doesn't set virtual thread name #40152

Closed
holgerstolzenberg opened this issue Apr 2, 2024 · 4 comments
Closed

Jetty support doesn't set virtual thread name #40152

holgerstolzenberg opened this issue Apr 2, 2024 · 4 comments
Assignees
Labels
type: bug A general bug
Milestone

Comments

@holgerstolzenberg
Copy link

holgerstolzenberg commented Apr 2, 2024

I am using Spring Boot 3.2.4 with Jetty (spring boot supplied version) in a 'standard' web mvc project.

When activating the virtual threads feature through configuration within application.yml the logging of the thread names disappears. I am using the default log pattern supplied by spring boot.

I suspect it is related to JettyVirtualThreadsWebServerFactoryCustomizer only using threadPool.setVirtualThreadsExecutor(VirtualThreads.getDefaultVirtualThreadsExecutor());.

The Jetty team has provided another factory method, making it possible to supply a name prefix for virtual threads:
jetty/jetty.project#11353 (comment)

Looking into the codebase of the supplied Jetty, this new factory method seems to be available to Spring Boot already.

My suggestion would be to use this new factory method and assign either a default or a configurable virtual thread name prefix from the Jetty auto configuration (or both 😬).

At least the logged thread name should not be empty when using virtual threads.

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Apr 2, 2024
@scottfrederick scottfrederick added type: bug A general bug and removed status: waiting-for-triage An issue we've not yet triaged labels Apr 2, 2024
@scottfrederick scottfrederick added this to the 3.2.x milestone Apr 2, 2024
@scottfrederick
Copy link
Contributor

The new method is available starting with Jetty 12.0.7, which Spring Boot is using as of version 3.2.4.

Spring Boot typically hard-codes a thread name prefix (for example, see #39748) but does not make the prefix configurable. I think that should be sufficient here also.

@holgerstolzenberg
Copy link
Author

I am totally fine with a hard coded thread name. Any chance this enhancement will make it to Spring Boot?

@philwebb
Copy link
Member

philwebb commented Apr 3, 2024

@holgerstolzenberg This one has been marked as a bug and it has a 3.2.x target. That means it's something we'd like to fix in a 3.2 release if possible.

@mhalbritter
Copy link
Contributor

@holgerstolzenberg The fix will be released in 3.2.5 on 2024-04-18.

@mhalbritter mhalbritter changed the title JettyVirtualThreadsWebServerFactoryCustomizer should use named virtual threads for better logging Jetty support doesn't set virtual thread name Apr 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: bug A general bug
Projects
None yet
Development

No branches or pull requests

5 participants