Deserialization issue w/ JavaBeans
SnakeYAML 1.8 Java Version: 1.8
Create a JavaBean class (ClassMustBe) that has a List<String> property called parameterSets
Call Yaml().loadAs(yamlString,ClassMustBe.class) with the yamlString being the following:
!test.bean.property parameterSets: !!java.lang.Object [!!java.io.FileOutputStream [file_created]]
Note that no exception is thrown, and the file is created. If you remove the parent java.lang.Object node, a argument type mismatch gets thrown, but the file still gets created.
I would expect that before creating a new instance of class that a check would be performed to make sure that the type is an appropriate one.
ConstructSequence.construct: if (foundConstructor) { try { return c.newInstance(argumentList.toArray()); } catch (Exception e) { throw new YAMLException(e); } } } }
Comments (4)
-
-
reporter - attached snakeyaml-javabeans.zip
I've attached the test I wrote earlier when looking into this. Running the
Test
file will create a newDifferentClass
object (which will print it's constructor args), as well as a new file titledfile_created
. test/test2.yaml files contain the payloads used in the loadAs method. -
The fact that you call a file a 'Test' does not make it a test.
If you write the an appropriate test where we can see what should succeed and what (and how) should fail - you make our life much easier.
I do not get this statement: "I would expect that before creating a new instance of class that a check would be performed to make sure that the type is an appropriate one." What you mean by 'appropriate' ?
-
- changed status to invalid
What to bother us if you do not intend to co-operate and answer the questions ?
- Log in to comment
This is exactly the case for a test to be provided.