From 251aaa1b229204044f3a755af26614d2efafc8e7 Mon Sep 17 00:00:00 2001 From: Guillaume Smet Date: Tue, 13 Aug 2024 18:34:05 +0200 Subject: [PATCH] Move optional free form map resolution to where it's already handled --- .../documentation/config/discovery/ResolvedType.java | 8 +------- .../documentation/config/resolver/ConfigResolver.java | 6 ++++-- 2 files changed, 5 insertions(+), 9 deletions(-) diff --git a/core/processor/src/main/java/io/quarkus/annotation/processor/documentation/config/discovery/ResolvedType.java b/core/processor/src/main/java/io/quarkus/annotation/processor/documentation/config/discovery/ResolvedType.java index 558e65cd4b42b..f10b93b94fa68 100644 --- a/core/processor/src/main/java/io/quarkus/annotation/processor/documentation/config/discovery/ResolvedType.java +++ b/core/processor/src/main/java/io/quarkus/annotation/processor/documentation/config/discovery/ResolvedType.java @@ -4,8 +4,6 @@ import javax.lang.model.type.DeclaredType; import javax.lang.model.type.TypeMirror; -import io.quarkus.annotation.processor.documentation.config.util.TypeUtil; - public record ResolvedType( TypeMirror wrapperType, TypeMirror unwrappedType, @@ -75,11 +73,7 @@ public static ResolvedType makeMap(TypeMirror type, ResolvedType unwrappedResolv unwrappedResolvedType.binaryName, unwrappedResolvedType.qualifiedName, unwrappedResolvedType.simplifiedName, unwrappedResolvedType.isPrimitive, true, unwrappedResolvedType.isList, - unwrappedResolvedType.isOptional - // backwards compatibility with versions before Quarkus 3.14 - // see https://github.com/quarkusio/quarkus/issues/42505 - || "java.lang.String".equals(unwrappedResolvedType.qualifiedName) - || TypeUtil.isPrimitiveWrapper(unwrappedResolvedType.qualifiedName), + unwrappedResolvedType.isOptional, unwrappedResolvedType.isDeclared, unwrappedResolvedType.isInterface, unwrappedResolvedType.isClass, unwrappedResolvedType.isEnum, unwrappedResolvedType.isDuration, unwrappedResolvedType.isConfigGroup); } diff --git a/core/processor/src/main/java/io/quarkus/annotation/processor/documentation/config/resolver/ConfigResolver.java b/core/processor/src/main/java/io/quarkus/annotation/processor/documentation/config/resolver/ConfigResolver.java index 88a4098ca0e50..377dc0484e568 100644 --- a/core/processor/src/main/java/io/quarkus/annotation/processor/documentation/config/resolver/ConfigResolver.java +++ b/core/processor/src/main/java/io/quarkus/annotation/processor/documentation/config/resolver/ConfigResolver.java @@ -172,9 +172,11 @@ private void resolveProperty(ConfigRoot configRoot, Map e } String potentiallyMappedPath = propertyPath; + boolean optional = discoveryConfigProperty.getType().isOptional(); if (discoveryConfigProperty.getType().isMap()) { - // it is a leaf pass through map + // it is a leaf pass through map, it is always optional + optional = true; typeQualifiedName = discoveryConfigProperty.getType().wrapperType().toString(); typeSimplifiedName = utils.element().simplifyGenericType(discoveryConfigProperty.getType().wrapperType()); @@ -192,7 +194,7 @@ private void resolveProperty(ConfigRoot configRoot, Map e discoveryConfigProperty.getSourceName(), potentiallyMappedPath, additionalPaths, ConfigNamingUtil.toEnvVarName(potentiallyMappedPath), typeQualifiedName, typeSimplifiedName, discoveryConfigProperty.getType().isMap(), discoveryConfigProperty.getType().isList(), - discoveryConfigProperty.getType().isOptional(), discoveryConfigProperty.getMapKey(), + optional, discoveryConfigProperty.getMapKey(), discoveryConfigProperty.isUnnamedMapKey(), context.isWithinMap(), discoveryConfigProperty.isConverted(), discoveryConfigProperty.getType().isEnum(),