Export to GitHub

snakeyaml - issue #9

Bean with no property cannot be instantiated


Posted on Jul 22, 2009 by Massive Kangaroo

The following yaml documents cannot be read, but should.

--- !!org.yaml.snakeyaml.noprop.BeanHolder bean : !!org.yaml.snakeyaml.noprop.Bean1

--- !!org.yaml.snakeyaml.noprop.BeanHolder

The attached patch contains testcases that reproduce the problem.

Attachments

Comment #1

Posted on Jul 24, 2009 by Massive Rhino

Thank you. This is in fact not a bug but a feature request. Because {} are not used for the leaf bean SnakeYAML tries to construct a scalar. Since there is no single-argument (the empty String as the argument) constructor it fails. Nevertheless this is an interesting case. I will think how we can improve the implementation.

Comment #2

Posted on Jul 27, 2009 by Massive Rhino

Question: if a Java instance is created out of following YAML document:

"!!com.package.Name" and 2 constructors are present in the Name class: no-argument constructor and with a String argument which constructor shall be used and why ?

Current situation:

"!!com.package.Name {}" - empty constructor is called

"!!com.package.Name" - constructor with an empty String is called

Comment #3

Posted on Aug 4, 2009 by Massive Rhino

Comment deleted

Comment #4

Posted on Aug 4, 2009 by Massive Rhino

Comment deleted

Comment #5

Posted on Aug 5, 2009 by Massive Rhino

Comment deleted

Comment #6

Posted on Aug 5, 2009 by Massive Rhino

Comment deleted

Comment #7

Posted on Aug 5, 2009 by Massive Rhino

Fixed.

Take the latest source and check: http://code.google.com/p/snakeyaml/source/browse/src/test/java/org/yaml/snakeyaml/issu es/issue9/NopropTest.java

The support is done via a custom Constructor (BeanConstructor). We need that because there is more then 1 way to create an instance.

Comment #8

Posted on Aug 6, 2009 by Grumpy Horse

(No comment was entered for this change.)

Status: Fixed

Labels:
Type-Enhancement Priority-Medium Milestone-Release1.4