Don't require empty objects when referencing custom components (#6891)
This commit is contained in:
parent
2a97eaedc5
commit
cde3d45f04
|
@ -21,6 +21,7 @@ import java.io.Closeable;
|
|||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.logging.Logger;
|
||||
|
@ -166,6 +167,9 @@ public final class FileConfiguration {
|
|||
Object model, ComponentLoader componentLoader) {
|
||||
Map<String, Object> configurationMap =
|
||||
MAPPER.convertValue(model, new TypeReference<Map<String, Object>>() {});
|
||||
if (configurationMap == null) {
|
||||
configurationMap = Collections.emptyMap();
|
||||
}
|
||||
return YamlStructuredConfigProperties.create(configurationMap, componentLoader);
|
||||
}
|
||||
|
||||
|
|
|
@ -130,4 +130,23 @@ class FileConfigurationCreateTest {
|
|||
"Closing io.opentelemetry.exporter.otlp.http.logs.OtlpHttpLogRecordExporter");
|
||||
logCapturer.assertContains("Closing io.opentelemetry.sdk.logs.export.BatchLogRecordProcessor");
|
||||
}
|
||||
|
||||
@Test
|
||||
void parseAndCreate_EmptyComponentProviderConfig() {
|
||||
String yaml =
|
||||
"file_format: \"0.3\"\n"
|
||||
+ "logger_provider:\n"
|
||||
+ " processors:\n"
|
||||
+ " - test:\n"
|
||||
+ "tracer_provider:\n"
|
||||
+ " processors:\n"
|
||||
+ " - test:\n";
|
||||
|
||||
assertThatCode(
|
||||
() ->
|
||||
FileConfiguration.parseAndCreate(
|
||||
new ByteArrayInputStream(yaml.getBytes(StandardCharsets.UTF_8))))
|
||||
.doesNotThrowAnyException();
|
||||
;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue