Skip to content

Commit

Permalink
Merge pull request #32561 from geoand/#32427
Browse files Browse the repository at this point in the history
Properly perform reflection registration for @Gauge instances
  • Loading branch information
ebullient committed Apr 12, 2023
2 parents c1657cd + ae117b9 commit 6e192b3
Showing 1 changed file with 8 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@
import io.quarkus.deployment.builditem.LaunchModeBuildItem;
import io.quarkus.deployment.builditem.ShutdownContextBuildItem;
import io.quarkus.deployment.builditem.nativeimage.ReflectiveClassBuildItem;
import io.quarkus.deployment.builditem.nativeimage.ReflectiveMethodBuildItem;
import io.quarkus.deployment.logging.LogCleanupFilterBuildItem;
import io.quarkus.deployment.metrics.MetricsCapabilityBuildItem;
import io.quarkus.deployment.metrics.MetricsFactoryConsumerBuildItem;
Expand Down Expand Up @@ -286,12 +285,18 @@ public void transform(TransformationContext context) {
*/
@BuildStep
void reflectiveMethodsWithGauges(BeanArchiveIndexBuildItem beanArchiveIndex,
BuildProducer<ReflectiveMethodBuildItem> reflectiveMethods) {
BuildProducer<ReflectiveClassBuildItem> reflectiveClass) {
Set<String> classNames = new HashSet<>();
for (AnnotationInstance annotation : beanArchiveIndex.getIndex().getAnnotations(GAUGE)) {
if (annotation.target().kind().equals(AnnotationTarget.Kind.METHOD)) {
reflectiveMethods.produce(new ReflectiveMethodBuildItem(annotation.target().asMethod()));
classNames.add(annotation.target().asMethod().declaringClass().name().toString());
}
}
if (!classNames.isEmpty()) {
reflectiveClass.produce(
ReflectiveClassBuildItem.builder(classNames.toArray(new String[0]))
.methods(true).constructors(true).build());
}
}

@BuildStep
Expand Down

0 comments on commit 6e192b3

Please sign in to comment.