Skip to content

Commit

Permalink
Move optional free form map resolution to where it's already handled
Browse files Browse the repository at this point in the history
  • Loading branch information
gsmet committed Aug 13, 2024
1 parent 1fb86f7 commit 251aaa1
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -172,9 +172,11 @@ private void resolveProperty(ConfigRoot configRoot, Map<String, ConfigSection> 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());

Expand All @@ -192,7 +194,7 @@ private void resolveProperty(ConfigRoot configRoot, Map<String, ConfigSection> 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(),
Expand Down

0 comments on commit 251aaa1

Please sign in to comment.