UcasRichard / snakeyaml

Automatically exported from code.google.com/p/snakeyaml
Apache License 2.0
0 stars 0 forks source link

Problem with Anchors for reference and object defined with compact notation #168

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
from org.yaml.snakeyaml.constructor.BaseConstructor, invoked from a set of 
elements meaning to content anchors to predefined references.
In 
org.yaml.snakeyaml.constructor.BaseConstructor.constructSequenceStep2(SequenceNo
de, Collection<Object>), Line 276 

It tries to construct a "referenced" element (Instead of referencing it) by 
it's compact notation definition, also having the ScalarNode instance with the 
property twoStepsConstruct in false.

What is the expected output? What do you see instead?
To use the reference is the expected behavior instead its creating a new object 
and without all the properties.

What version of SnakeYAML are you using? On what Java version?
1.11

Please provide any additional information below. (Often a failing test is
the best way to describe the problem.)

The problem is more clear with the following example

# Roles
- &rolPM Role(1, name = PM):
    importance: 3

This will load a Role object with three properties setted id, name and 
importance.

# Employees
- &e001 Employee(1, userName = juan):
    roles:
        - *rolPM

This with the problem described, will load and employee with three properties, 
id =1, username = juan.obes and a set with 1 element, but this element is a new 
Role instance with id = 1, PM = juan, but importance in NULL

Original issue reported on code.google.com by andres.c...@globant.com on 22 Jan 2013 at 4:09

GoogleCodeExporter commented 9 years ago
Errata in the last paragraph
This with the problem described, will load an employee with three properties, 
id =1, username = juan and roles as a set with 1 element, but this element is a 
new Role instance with id = 1, PM = juan, but importance = NULL

Original comment by andres.c...@globant.com on 22 Jan 2013 at 4:11

GoogleCodeExporter commented 9 years ago
If you can deliver a failing JUnit test, I can look at the problem straight 
away.

Original comment by py4fun@gmail.com on 22 Jan 2013 at 5:24