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

Throw an exception without setting configuredProvider to null when ge… #462

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion api/src/main/java/jakarta/enterprise/inject/spi/CDI.java
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
public abstract class CDI<T> implements Instance<T> {

private static final Object lock = new Object();
private static volatile boolean providerSetManually = false;
protected static volatile Set<CDIProvider> discoveredProviders = null;
protected static volatile CDIProvider configuredProvider = null;

Expand Down Expand Up @@ -77,7 +78,11 @@ private static CDIProvider getCDIProvider() {
if (configuredProvider != null && configuredProvider.getCDI() != null) {
return configuredProvider;
}
} catch (IllegalStateException ignored) {
} catch (IllegalStateException e) {
//if the provider is set manually we do not look for a different provider.
if (providerSetManually) {
throw e;
}
}
configuredProvider = null;
// Discover providers and cache
Expand Down Expand Up @@ -116,6 +121,7 @@ private static boolean checkProvider(CDIProvider c) {
*/
public static void setCDIProvider(CDIProvider provider) {
if (provider != null) {
providerSetManually = true;
configuredProvider = provider;
} else {
throw new IllegalStateException("CDIProvider must not be null");
Expand Down