Ramiro Aparicio created CONFIGURATION-859:
---------------------------------------------
Summary: YAMLConfiguration silently drops valid non-cyclic
map/list aliases after cycle-detection change
Key: CONFIGURATION-859
URL: https://issues.apache.org/jira/browse/CONFIGURATION-859
Project: Commons Configuration
Issue Type: Bug
Affects Versions: 2.15.0
Environment: Locally reproduced with:
* Apache Commons Configuration *2.15.1*
* SnakeYAML *2.7*
* Java *21*
Reporter: Ramiro Aparicio
Commons Configuration *2.15.0* silently drops valid YAML aliases referencing
previously processed maps or lists.
The YAML contains shared references, but {*}no recursive references or
cycles{*}. The same configuration loads correctly with {*}2.12.0{*}.
This appears to be a regression introduced by [PR #634: Detect and avoid
processing cycles in YAML
input|https://github.com/apache/commons-configuration/pull/634].
For comparison, Commons Configuration *2.12.0* loads all entries correctly with
the same SnakeYAML version and Java runtime.
h2. Minimal reproduction{{{}{}}}
Run the following Java program:
{{{{}}}}
{code:java}
import java.io.StringReader;
import org.apache.commons.configuration2.YAMLConfiguration;
public class YamlAliasReproducer {
public static void main(String[] args) throws Exception {
String yaml = """
financial-distress:
hardships:
standard: &writer
- host: fixture-clone.invalid
db: hardships
port: 3306
user: fixture
password: fixture-password
direct: *writer
direct_ro: *writer
ro:
- host: fixture-clone-reader.invalid
db: hardships
port: 3306
user: fixture
password: fixture-password
""";
YAMLConfiguration configuration = new YAMLConfiguration();
configuration.read(new StringReader(yaml));
for (String connection :
new String[] {"standard", "direct", "direct_ro", "ro"}) {
String key =
"financial-distress.hardships." + connection + ".host";
System.out.println(
connection + "=" + configuration.getProperty(key));
}
}
}{code}
{{{{}}}}
h2. Expected behavior
{{{{}}}}
The three writer connection entries should resolve to the same host:
{{{{}}}}
{{{{}}}}
{code:java}
{code}
{{standard=fixture-clone.invalid }}
{{direct=fixture-clone.invalid }}
{{direct_ro=fixture-clone.invalid }}
{{ro=fixture-clone-reader.invalid}}
{{}}
This is the observed output with Commons Configuration {*}2.12.0{*}.
{{{{}}}}
h2. Actual behavior
{{{{}}}}
With Commons Configuration {*}2.15.1{*}:
{{{{}}}}
{{{{}}}}
{code:java}
standard=fixture-clone.invalid
direct=null
direct_ro=null
ro=fixture-clone-reader.invalid{code}
{{{{{}{}}}{{{}{}}}}}
Probably related to: https://issues.apache.org/jira/browse/CONFIGURATION-849
But I'm not sure whether it is the same bug.
{{{{}}}}
--
This message was sent by Atlassian Jira
(v8.20.10#820010)