Skip to content

Commit

Permalink
Merge pull request #23946 from radcortez/fix-arc-npe
Browse files Browse the repository at this point in the history
Fix Arc NPE if `quarkus.arc.remove-unused-beans` is false
  • Loading branch information
geoand authored Feb 24, 2022
2 parents 60426de + b6862e4 commit ed30044
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 6 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package io.quarkus.arc.deployment.devconsole;

import java.util.Collection;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
Expand Down Expand Up @@ -108,14 +109,20 @@ public DevConsoleTemplateInfoBuildItem collectBeanInfo(ValidationPhaseBuildItem
for (InterceptorInfo interceptor : validationContext.get(BuildExtension.Key.INTERCEPTORS)) {
beanInfos.addInterceptor(DevInterceptorInfo.from(interceptor, predicate));
}
for (InterceptorInfo interceptor : validationContext.get(BuildExtension.Key.REMOVED_INTERCEPTORS)) {
beanInfos.addRemovedInterceptor(DevInterceptorInfo.from(interceptor, predicate));
Collection<InterceptorInfo> removedInterceptors = validationContext.get(BuildExtension.Key.REMOVED_INTERCEPTORS);
if (removedInterceptors != null) {
for (InterceptorInfo interceptor : removedInterceptors) {
beanInfos.addRemovedInterceptor(DevInterceptorInfo.from(interceptor, predicate));
}
}
for (DecoratorInfo decorator : validationContext.get(BuildExtension.Key.DECORATORS)) {
beanInfos.addDecorator(DevDecoratorInfo.from(decorator, predicate));
}
for (DecoratorInfo decorator : validationContext.get(BuildExtension.Key.REMOVED_DECORATORS)) {
beanInfos.addRemovedDecorator(DevDecoratorInfo.from(decorator, predicate));
Collection<DecoratorInfo> removedDecorators = validationContext.get(BuildExtension.Key.REMOVED_DECORATORS);
if (removedDecorators != null) {
for (DecoratorInfo decorator : removedDecorators) {
beanInfos.addRemovedDecorator(DevDecoratorInfo.from(decorator, predicate));
}
}
beanInfos.sort();
return new DevConsoleTemplateInfoBuildItem("devBeanInfos", beanInfos);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package io.quarkus.vertx.http.deployment.devmode;

import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
Expand All @@ -12,6 +13,8 @@
import io.quarkus.arc.deployment.ValidationPhaseBuildItem.ValidationErrorBuildItem;
import io.quarkus.arc.processor.BeanInfo;
import io.quarkus.arc.processor.BuildExtension;
import io.quarkus.arc.processor.DecoratorInfo;
import io.quarkus.arc.processor.InterceptorInfo;
import io.quarkus.deployment.IsDevelopment;
import io.quarkus.deployment.annotations.BuildProducer;
import io.quarkus.deployment.annotations.BuildStep;
Expand All @@ -34,8 +37,15 @@ void registerRoutes(ArcConfig arcConfig, ArcDevRecorder recorder,
BuildProducer<ValidationErrorBuildItem> errors) {

List<BeanInfo> removed = new ArrayList<>();
removed.addAll(validationPhase.getContext().get(BuildExtension.Key.REMOVED_INTERCEPTORS));
removed.addAll(validationPhase.getContext().get(BuildExtension.Key.REMOVED_DECORATORS));
Collection<InterceptorInfo> removedInterceptors = validationPhase.getContext()
.get(BuildExtension.Key.REMOVED_INTERCEPTORS);
if (removedInterceptors != null) {
removed.addAll(removedInterceptors);
}
Collection<DecoratorInfo> removedDecorators = validationPhase.getContext().get(BuildExtension.Key.REMOVED_DECORATORS);
if (removedDecorators != null) {
removed.addAll(removedDecorators);
}
List<String[]> removedInterceptorsDecorators;
if (removed.isEmpty()) {
removedInterceptorsDecorators = Collections.emptyList();
Expand Down

0 comments on commit ed30044

Please sign in to comment.