Merge branch '3.2.x'

Closes gh-40691
This commit is contained in:
Andy Wilkinson 2024-05-10 12:37:39 +01:00
commit 772e4ca78d
2 changed files with 8 additions and 5 deletions

View File

@ -1,5 +1,5 @@
/* /*
* Copyright 2012-2023 the original author or authors. * Copyright 2012-2024 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -51,7 +51,7 @@ class InvalidConfigurationPropertyValueFailureAnalyzer
protected FailureAnalysis analyze(Throwable rootFailure, InvalidConfigurationPropertyValueException cause) { protected FailureAnalysis analyze(Throwable rootFailure, InvalidConfigurationPropertyValueException cause) {
List<Descriptor> descriptors = getDescriptors(cause.getName()); List<Descriptor> descriptors = getDescriptors(cause.getName());
if (descriptors.isEmpty()) { if (descriptors.isEmpty()) {
return null; descriptors = List.of(new Descriptor(null, cause.getValue(), null));
} }
StringBuilder description = new StringBuilder(); StringBuilder description = new StringBuilder();
appendDetails(description, cause, descriptors); appendDetails(description, cause, descriptors);

View File

@ -1,5 +1,5 @@
/* /*
* Copyright 2012-2023 the original author or authors. * Copyright 2012-2024 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -45,7 +45,8 @@ class InvalidConfigurationPropertyValueFailureAnalyzerTests {
InvalidConfigurationPropertyValueException failure = new InvalidConfigurationPropertyValueException( InvalidConfigurationPropertyValueException failure = new InvalidConfigurationPropertyValueException(
"test.property", "invalid", "This is not valid."); "test.property", "invalid", "This is not valid.");
FailureAnalysis analysis = new InvalidConfigurationPropertyValueFailureAnalyzer(null).analyze(failure); FailureAnalysis analysis = new InvalidConfigurationPropertyValueFailureAnalyzer(null).analyze(failure);
assertThat(analysis).isNull(); assertThat(analysis.getDescription())
.contains("Invalid value 'invalid' for configuration property 'test.property'.");
} }
@Test @Test
@ -98,7 +99,9 @@ class InvalidConfigurationPropertyValueFailureAnalyzerTests {
void analysisWithUnknownKey() { void analysisWithUnknownKey() {
InvalidConfigurationPropertyValueException failure = new InvalidConfigurationPropertyValueException( InvalidConfigurationPropertyValueException failure = new InvalidConfigurationPropertyValueException(
"test.key.not.defined", "invalid", "This is not valid."); "test.key.not.defined", "invalid", "This is not valid.");
assertThat(performAnalysis(failure)).isNull(); FailureAnalysis analysis = performAnalysis(failure);
assertThat(analysis.getDescription())
.contains("Invalid value 'invalid' for configuration property 'test.key.not.defined'.");
} }
private void assertCommonParts(InvalidConfigurationPropertyValueException failure, FailureAnalysis analysis) { private void assertCommonParts(InvalidConfigurationPropertyValueException failure, FailureAnalysis analysis) {