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

Avoid intializing CDI beans in STATIC_INIT #1047

Merged
merged 1 commit into from
Sep 17, 2021
Merged
Show file tree
Hide file tree
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
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,9 @@ public Class<?> getClass(Class<?> declaringClass) {
public Object getInstance(Class<?> declaringClass) {
return CDI.current().select(declaringClass).get();
}

@Override
public boolean isResolvable(Class<?> declaringClass) {
return CDI.current().select(declaringClass).isResolvable();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -139,10 +139,8 @@ private void verifyInjectionIsAvailable() {
.flatMap(stream -> stream)
.distinct().forEach(beanClassName -> {
// verify that the bean is injectable
try {
lookupService.getClass(classloadingService.loadClass(beanClassName));
} catch (Exception e) {
throw SmallRyeGraphQLServerMessages.msg.canNotInjectClass(beanClassName, e);
if (!lookupService.isResolvable(classloadingService.loadClass(beanClassName))) {
throw SmallRyeGraphQLServerMessages.msg.canNotInjectClass(beanClassName, null);
}
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ static LookupService load() {

Object getInstance(Class<?> declaringClass);

boolean isResolvable(Class<?> declaringClass);

/**
* Default Lookup service that gets used when none is provided with SPI.
* This use reflection
Expand All @@ -65,5 +67,10 @@ public Object getInstance(Class<?> declaringClass) {
throw msg.countNotGetInstance(ex);
}
}

@Override
public boolean isResolvable(Class<?> declaringClass) {
return true;
}
}
}