Skip to content

Commit d805bd8

Browse files
committed
Update to Jandex 3.5.2, use several new APIs for efficiency improvements
Signed-off-by: Michael Edgar <michael@xlate.io>
1 parent 685a426 commit d805bd8

File tree

5 files changed

+44
-12
lines changed

5 files changed

+44
-12
lines changed

core/src/main/java/io/smallrye/openapi/runtime/io/Names.java

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,35 @@ public static DotName containerOf(DotName repeatable) {
7474
return repeatContainers.get(repeatable);
7575
}
7676

77+
/**
78+
* Create componentized {@link DotName} instances for the given collection of
79+
* names. The results will be returned in a map, keyed by the input element from
80+
* which each entry was derived.
81+
*/
82+
public static Map<String, DotName> componentize(Collection<String> names) {
83+
Map<DotName, DotName> workingSet = new HashMap<>();
84+
Map<String, DotName> results = new HashMap<>();
85+
86+
for (String name : names) {
87+
String[] elements = name.split("\\.");
88+
DotName current = null;
89+
90+
for (String element : elements) {
91+
current = DotName.createComponentized(current, element);
92+
93+
if (workingSet.containsKey(current)) {
94+
current = workingSet.get(current);
95+
} else {
96+
workingSet.put(current, current);
97+
}
98+
}
99+
100+
results.put(name, current);
101+
}
102+
103+
return results;
104+
}
105+
77106
public static final DotName OPENAPI_DEFINITION = createIndexable(OpenAPIDefinition.class);
78107
public static final DotName API_RESPONSE = createIndexable(APIResponse.class);
79108
public static final DotName API_RESPONSES = createIndexable(APIResponses.class);

core/src/main/java/io/smallrye/openapi/runtime/scanner/dataobject/AugmentedIndexView.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ public Map<ClassInfo, MethodInfo> ancestry(MethodInfo method) {
130130
}
131131

132132
private static boolean saveOverride(MethodInfo searchMethod, ClassInfo clazz, Map<ClassInfo, MethodInfo> results) {
133-
MethodInfo classMethod = clazz.method(searchMethod.name(), searchMethod.parameterTypes());
133+
MethodInfo classMethod = clazz.method(searchMethod);
134134

135135
if (classMethod != null && !classMethod.isSynthetic()) {
136136
results.put(clazz, classMethod);

core/src/main/java/io/smallrye/openapi/runtime/util/Annotations.java

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
import org.jboss.jandex.PrimitiveType.Primitive;
2727
import org.jboss.jandex.Type;
2828

29+
import io.smallrye.openapi.runtime.io.Names;
2930
import io.smallrye.openapi.runtime.scanner.dataobject.AugmentedIndexView;
3031
import io.smallrye.openapi.runtime.scanner.spi.AnnotationScannerContext;
3132

@@ -54,15 +55,12 @@ public final class Annotations {
5455
}
5556

5657
private final AnnotationScannerContext context;
57-
private final Set<String> excludedPackages;
58+
private final Collection<DotName> excludedPackages;
5859

5960
public Annotations(AnnotationScannerContext context) {
6061
this.context = context;
61-
this.excludedPackages = context.getConfig()
62-
.getScanCompositionExcludePackages()
63-
.stream()
64-
.map(pkg -> pkg.concat("."))
65-
.collect(Collectors.toSet());
62+
this.excludedPackages = Names.componentize(context.getConfig().getScanCompositionExcludePackages())
63+
.values();
6664
}
6765

6866
private static Collection<AnnotationInstance> getDeclaredAnnotations(AnnotationTarget target) {
@@ -90,10 +88,8 @@ private static List<AnnotationInstance> declaredFieldAnnotations(FieldInfo field
9088
}
9189

9290
private boolean composable(DotName annotation) {
93-
String name = annotation.toString();
94-
95-
for (String pkg : this.excludedPackages) {
96-
if (name.startsWith(pkg)) {
91+
for (DotName pkg : this.excludedPackages) {
92+
if (annotation.startsWith(pkg)) {
9793
return false;
9894
}
9995
}

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
<version.buildhelper.plugin>3.6.1</version.buildhelper.plugin>
2121
<jackson-bom.version>2.20.1</jackson-bom.version>
2222
<version.eclipse.microprofile.config>3.0.3</version.eclipse.microprofile.config>
23-
<version.io.smallrye.jandex>3.5.1</version.io.smallrye.jandex>
23+
<version.io.smallrye.jandex>3.5.2</version.io.smallrye.jandex>
2424
<version.io.smallrye.smallrye-config>3.14.1</version.io.smallrye.smallrye-config>
2525
<version.io.smallrye.smallrye-common-classloader>2.14.0</version.io.smallrye.smallrye-common-classloader>
2626
<version.eclipse.microprofile.openapi>4.1.1</version.eclipse.microprofile.openapi>

testsuite/data/pom.xml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
<quarkus.platform.artifact-id>quarkus-bom</quarkus.platform.artifact-id>
2323
<quarkus.platform.group-id>io.quarkus</quarkus.platform.group-id>
2424
<quarkus.platform.version>3.29.2</quarkus.platform.version>
25+
<version.io.smallrye.jandex>3.5.2</version.io.smallrye.jandex>
2526
<quarkus.package.type>uber-jar</quarkus.package.type>
2627
<quarkus.package.add-runner-suffix>false</quarkus.package.add-runner-suffix>
2728
</properties>
@@ -43,6 +44,12 @@
4344
<artifactId>microprofile-openapi-api</artifactId>
4445
<version>${eclipse.microprofile.openapi.version}</version>
4546
</dependency>
47+
<dependency>
48+
<!-- This can be removed when upgrading Quarkus to a version including Jandex 3.5.2+ -->
49+
<groupId>io.smallrye</groupId>
50+
<artifactId>jandex</artifactId>
51+
<version>${version.io.smallrye.jandex}</version>
52+
</dependency>
4653
<dependency>
4754
<groupId>${quarkus.platform.group-id}</groupId>
4855
<artifactId>${quarkus.platform.artifact-id}</artifactId>

0 commit comments

Comments
 (0)