-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
Improve AutoExtensionRegistration behavior with filtering #4418
Comments
Which version of Java are you using to run your tests? |
java-17 |
We're already applying the filter before instantiating the registered class on Java 9+: https://github.com/junit-team/junit5/blob/main/junit-platform-commons/src/main/java9/org/junit/platform/commons/util/ServiceLoaderUtils.java It seems that's not enough? Could you please share a reproducer? |
This override implementation should work, I am suspecting jvm is picking standard implementation instead of override implementation. We use bazel, so might be a setup issue. |
Could you please share a stacktrace? |
Verified that both versions fail. Instead of using a stream, we likely need to switch to a safe iterator with a try-catch around hasNext.
|
Seems like already the initialization of the provider class fails - perhaps due to some static code reaching out to in this setup non-existing classes. I see two options here:
|
static {
TestSignalHandler.register();
} This should be moved into a non-static context. |
In order to catch ServiceConfigurationError (as described in ServiceLoader API documentation) and ignore them based on
I think that JUnit should not try to mend such configuration errors. Either:
In the light of the above, I tend to close the issue as "won't fix" or "not planned". |
When using AutoExtensionRegistration together with the include and exclude properties, the ServiceLoader should not throw an exception for extensions that would be filtered out anyway.
Currently, this causes issues when a /META-INF/services/org.junit.jupiter.api.extension.Extension file exists in a third-party dependency and references an extension class that is unavailable at runtime. Even though this extension would be excluded by the filtering configuration, the test execution fails to start due to the loading failure.
Let me know if this enhancements make sense, I will raise the PR for the same.
The text was updated successfully, but these errors were encountered: