From 1fb86f76ad85d05690c6c13ba0fa8c207a04df21 Mon Sep 17 00:00:00 2001 From: Peter Palaga Date: Tue, 13 Aug 2024 14:55:08 +0200 Subject: [PATCH 1/2] Freeform Map configuration properties always marked as required, fix #42505 --- .../documentation/config/discovery/ResolvedType.java | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) 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 f10b93b94fa68..558e65cd4b42b 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,6 +4,8 @@ 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, @@ -73,7 +75,11 @@ public static ResolvedType makeMap(TypeMirror type, ResolvedType unwrappedResolv unwrappedResolvedType.binaryName, unwrappedResolvedType.qualifiedName, unwrappedResolvedType.simplifiedName, unwrappedResolvedType.isPrimitive, true, unwrappedResolvedType.isList, - unwrappedResolvedType.isOptional, + 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.isDeclared, unwrappedResolvedType.isInterface, unwrappedResolvedType.isClass, unwrappedResolvedType.isEnum, unwrappedResolvedType.isDuration, unwrappedResolvedType.isConfigGroup); } From 251aaa1b229204044f3a755af26614d2efafc8e7 Mon Sep 17 00:00:00 2001 From: Guillaume Smet Date: Tue, 13 Aug 2024 18:34:05 +0200 Subject: [PATCH 2/2] 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(),