Skip to content

Commit

Permalink
Merge pull request #1047 from jmartisk/main-quarkus-20199
Browse files Browse the repository at this point in the history
Avoid intializing CDI beans in STATIC_INIT
  • Loading branch information
phillip-kruger authored Sep 17, 2021
2 parents 3f21386 + 439c112 commit 93ac461
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 4 deletions.
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;
}
}
}

0 comments on commit 93ac461

Please sign in to comment.