Skip to content

Commit 9421b85

Browse files
committed
Ensure that a large numbers of REST Client interfaces doesn't break the build
Fixes: quarkusio#49933
1 parent b1bb7ad commit 9421b85

File tree

1 file changed

+18
-11
lines changed

1 file changed

+18
-11
lines changed

extensions/resteasy-reactive/rest-client/deployment/src/main/java/io/quarkus/rest/client/reactive/deployment/RestClientReactiveProcessor.java

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -353,7 +353,7 @@ void registerProvidersFromAnnotations(CombinedIndexBuildItem indexBuildItem,
353353

354354
}
355355

356-
addGeneratedProviders(index, constructor, annotationsByClassName, generatedProviders);
356+
addGeneratedProviders(index, classCreator, constructor, annotationsByClassName, generatedProviders);
357357

358358
constructor.returnValue(null);
359359
}
@@ -779,11 +779,13 @@ private Map<String, GeneratedClassResult> populateClientProviderFromAnnotations(
779779
return result;
780780
}
781781

782-
private void addGeneratedProviders(IndexView index, MethodCreator constructor,
782+
private void addGeneratedProviders(IndexView index, ClassCreator classCreator, MethodCreator constructor,
783783
Map<String, List<AnnotationInstance>> annotationsByClassName,
784784
Map<String, List<GeneratedClassResult>> generatedProviders) {
785+
int i = 1;
785786
for (Map.Entry<String, List<AnnotationInstance>> annotationsForClass : annotationsByClassName.entrySet()) {
786-
ResultHandle map = constructor.newInstance(MethodDescriptor.ofConstructor(HashMap.class));
787+
MethodCreator mc = classCreator.getMethodCreator("addGeneratedProviders" + i, void.class);
788+
ResultHandle map = mc.newInstance(MethodDescriptor.ofConstructor(HashMap.class));
787789
for (AnnotationInstance value : annotationsForClass.getValue()) {
788790
String className = value.value().asString();
789791
AnnotationValue priorityAnnotationValue = value.value("priority");
@@ -794,21 +796,26 @@ private void addGeneratedProviders(IndexView index, MethodCreator constructor,
794796
priority = priorityAnnotationValue.asInt();
795797
}
796798

797-
constructor.invokeInterfaceMethod(MAP_PUT, map, constructor.loadClassFromTCCL(className),
798-
constructor.load(priority));
799+
mc.invokeInterfaceMethod(MAP_PUT, map, mc.loadClassFromTCCL(className),
800+
mc.load(priority));
799801
}
800802
String ifaceName = annotationsForClass.getKey();
801803
if (generatedProviders.containsKey(ifaceName)) {
802804
// remove the interface from the generated provider since it's going to be handled now
803805
// the remaining entries will be handled later
804806
List<GeneratedClassResult> providers = generatedProviders.remove(ifaceName);
805807
for (GeneratedClassResult classResult : providers) {
806-
constructor.invokeInterfaceMethod(MAP_PUT, map, constructor.loadClass(classResult.generatedClassName),
807-
constructor.load(classResult.priority));
808+
mc.invokeInterfaceMethod(MAP_PUT, map, mc.loadClass(classResult.generatedClassName),
809+
mc.load(classResult.priority));
808810
}
809811

810812
}
811-
addProviders(constructor, ifaceName, map);
813+
addProviders(mc, ifaceName, map);
814+
mc.returnVoid();
815+
816+
constructor.invokeVirtualMethod(mc.getMethodDescriptor(), constructor.getThis());
817+
818+
i++;
812819
}
813820

814821
for (Map.Entry<String, List<GeneratedClassResult>> entry : generatedProviders.entrySet()) {
@@ -822,11 +829,11 @@ private void addGeneratedProviders(IndexView index, MethodCreator constructor,
822829
}
823830
}
824831

825-
private void addProviders(MethodCreator constructor, String providerClass, ResultHandle map) {
826-
constructor.invokeVirtualMethod(
832+
private void addProviders(MethodCreator mc, String providerClass, ResultHandle map) {
833+
mc.invokeVirtualMethod(
827834
MethodDescriptor.ofMethod(AnnotationRegisteredProviders.class, "addProviders", void.class, String.class,
828835
Map.class),
829-
constructor.getThis(), constructor.load(providerClass), map);
836+
mc.getThis(), mc.load(providerClass), map);
830837
}
831838

832839
private int getAnnotatedPriority(IndexView index, String className, int defaultPriority) {

0 commit comments

Comments
 (0)