-
Notifications
You must be signed in to change notification settings - Fork 41k
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
Add info contributor support for JDK 24's VirtualThreadSchedulerMXBean #43594
Add info contributor support for JDK 24's VirtualThreadSchedulerMXBean #43594
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks very much for the PR. I've added some review comments for your consideration.
spring-boot-project/spring-boot/src/main/java/org/springframework/boot/info/ProcessInfo.java
Outdated
Show resolved
Hide resolved
spring-boot-project/spring-boot/src/main/java/org/springframework/boot/info/ProcessInfo.java
Outdated
Show resolved
Hide resolved
spring-boot-project/spring-boot/src/main/java/org/springframework/boot/info/ProcessInfo.java
Outdated
Show resolved
Hide resolved
spring-boot-project/spring-boot/src/main/java/org/springframework/boot/info/ProcessInfo.java
Outdated
Show resolved
Hide resolved
...g-boot-project/spring-boot/src/test/java/org/springframework/boot/info/ProcessInfoTests.java
Outdated
Show resolved
Hide resolved
...g-boot-project/spring-boot/src/test/java/org/springframework/boot/info/ProcessInfoTests.java
Outdated
Show resolved
Hide resolved
...g-boot-project/spring-boot/src/test/java/org/springframework/boot/info/ProcessInfoTests.java
Outdated
Show resolved
Hide resolved
I think we could add something to the existing test just to check that we have sensible(ish) values. |
6edc540
to
d898b44
Compare
d898b44
to
1f1b9b8
Compare
Thank you very much and congratulations on your first contribution 🎉! |
Since reflection is being used here, I wonder whether static class ProcessInfoContributorRuntimeHints implements RuntimeHintsRegistrar {
private final BindingReflectionHintsRegistrar bindingRegistrar = new BindingReflectionHintsRegistrar();
@Override
public void registerHints(RuntimeHints hints, ClassLoader classLoader) {
this.bindingRegistrar.registerReflectionHints(hints.reflection(), ProcessInfo.class);
hints.reflection()
.registerTypeIfPresent(classLoader, "jdk.management.VirtualThreadSchedulerMXBean",
MemberCategory.INVOKE_PUBLIC_METHODS);
}
} |
Yeah, good catch. I'll add that. |
In this commit, for applications using Spring with JDK 24, I added support for viewing Virtual threads information in
ProcessInfo
usingVirtualThreadSchedulerMXBean
. The use ofVirtualThreadSchedulerMXBean
is done using reflection. If the current JDK version is less than 24, then we will return null, otherwise a class with all the requiredVirtualThreadsInfo
information.I also added a test checking if null is returned if the JDK version is less than 24.
There is also a point that bothers me, do you think we need an additional test to check the values of the
VirtualThreadsInfo
fields themselves or not?Related to #43175