Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Take into account that configuration properties can contain a dot in …
Browse files Browse the repository at this point in the history
…RunTimeConfigurationGenerator

Otherwise we sometimes get a bug where Quarkus would get to the wrong index
when parsing a configuration property, and would end up mistakenly
reporting missing configuration properties (in a really puzzling error
message...).
yrodiere committed Jul 27, 2022
1 parent 314c240 commit 888267d
Showing 1 changed file with 17 additions and 12 deletions.
Original file line number Diff line number Diff line change
@@ -1310,10 +1310,7 @@ private MethodDescriptor generateParserBody(final ConfigPatternMap<Container> ke
if (matched instanceof FieldContainer) {
final FieldContainer fieldContainer = (FieldContainer) matched;
if (dynamic) {
if (!itemMember.getPropertyName().isEmpty()) {
// consume segment
matchedBody.invokeVirtualMethod(NI_PREVIOUS, keyIter);
}
generateConsumeSegments(matchedBody, keyIter, itemMember.getPropertyName());
// we have to get or create all containing (and contained) groups of this member
matchedBody.invokeStaticMethod(generateGetEnclosing(fieldContainer, type), keyIter,
config);
@@ -1467,10 +1464,7 @@ private MethodDescriptor generateGetEnclosing(final FieldContainer matchNode, fi
// get the parent
final FieldContainer fieldContainer = (FieldContainer) parent;
final ClassDefinition.ClassMember classMember = fieldContainer.getClassMember();
if (!classMember.getPropertyName().isEmpty()) {
// consume segment
mc.invokeVirtualMethod(NI_PREVIOUS, keyIter);
}
generateConsumeSegments(mc, keyIter, classMember.getPropertyName());
final ResultHandle enclosing = mc.invokeStaticMethod(generateGetEnclosing(fieldContainer, type),
keyIter, config);

@@ -1576,10 +1570,7 @@ private MethodDescriptor generateGetEnclosing(final MapContainer matchNode, fina
if (parent instanceof FieldContainer) {
// get the parent
final FieldContainer fieldContainer = (FieldContainer) parent;
if (!fieldContainer.getClassMember().getPropertyName().isEmpty()) {
// consume segment
mc.invokeVirtualMethod(NI_PREVIOUS, keyIter);
}
generateConsumeSegments(mc, keyIter, fieldContainer.getClassMember().getPropertyName());
final ResultHandle enclosing = mc.invokeStaticMethod(generateGetEnclosing(fieldContainer, type),
keyIter, config);
if (!fieldContainer.getClassMember().getPropertyName().isEmpty()) {
@@ -1619,6 +1610,20 @@ private MethodDescriptor generateGetEnclosing(final MapContainer matchNode, fina
return md;
}

private void generateConsumeSegments(BytecodeCreator bc, ResultHandle keyIter, String propertyName) {
if (propertyName.isEmpty()) {
return;
}
bc.invokeVirtualMethod(NI_PREVIOUS, keyIter);
// For properties whose name contains dots,
// we need to call previous() multiple times
int dotIndex = propertyName.indexOf('.');
while (dotIndex >= 0) {
bc.invokeVirtualMethod(NI_PREVIOUS, keyIter);
dotIndex = propertyName.indexOf('.', dotIndex + 1);
}
}

private FieldDescriptor getOrCreateConverterInstance(Field field) {
return getOrCreateConverterInstance(field, ConverterType.of(field));
}

0 comments on commit 888267d

Please sign in to comment.