Skip to content

Add support for JSON and YAML configurations - #514

Closed
rgoers wants to merge 2 commits into
trunkfrom
add-json-and-yaml
Closed

rgoers wants to merge 2 commits into
trunkfrom
add-json-and-yaml

Conversation

@rgoers

@rgoers rgoers commented Oct 29, 2026

Copy link
Copy Markdown
Member

Also fixes some minor PMD issues.

@rgoers
rgoers requested a review from ppkarwasz October 29, 2026 20:26

@ppkarwasz ppkarwasz left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @rgoers,

As currently written, only a single YAML file can be used as source. Is this intentional? If we use Java *.properties file, Flume will ignore and log loading errors for distinct configuration files. Is this by design or an uncaught bug?

Comment thread flume-ng-node/pom.xml
<groupId>org.snakeyaml</groupId>
<artifactId>snakeyaml-engine</artifactId>
<version>${snake-yaml.version}</version>
<optional>true</optional>

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it is fine to add it as required dependency.

Comment on lines +206 to +213
boolean isYaml;
try {
Class.forName("org.snakeyaml.engine.v2.api.Load");
isYaml = true;
} catch (Exception exception) {
isYaml = false;
}
isYamlSupported = isYaml;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

…which of course will remove the need for reflection.

case ConfigurationSource.YAML:
case ConfigurationSource.YML: {
if (isYamlSupported) {
properties = YamlConfigConverter.convertYamlToProperties(is);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should append the properties from multiple sources instead of replacing them.

Suggested change
properties = YamlConfigConverter.convertYamlToProperties(is);
properties.putAll(YamlConfigConverter.convertYamlToProperties(is));

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is going to be my next PR.

Load load = new Load(settings);

// 2. Load the YAML content into basic Java structures
Object yamlData = load.loadFromInputStream(yamlInputStream);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This can throw a YamlEngineException, which, unlike Properties.load will not be caught in the UriConfigurationProvider loop.

If one source is defective, the entire configuration will fail.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will fix this in the next PR.

@rgoers

rgoers commented Nov 3, 2026

Copy link
Copy Markdown
Member Author

Closing this since all the changes were incorporated in 515.

@rgoers rgoers closed this Nov 3, 2026
@ppkarwasz
ppkarwasz deleted the add-json-and-yaml branch November 3, 2026 22:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants