yeison / snakeyaml

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

dumpAll is missing first document separator "---" (version 1.12) #180

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. call yaml.dumpAll(Iterator) method 
2. pass in the output back into yaml.loadAll(String)

What is the expected output? What do you see instead?
expected output to start with "---"
actual output did not start with "---"

What version of SnakeYAML are you using? On what Java version?
Snakeyaml 1.12, Java 1,6

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

Here is some test code:

        ArrayList<String> strings = new ArrayList<String>();
        strings.add("1");
        strings.add("2");
        strings.add("3");
        output = yaml.dumpAll(strings.iterator());
        System.out.println("dumpAll strings:\n" + output);

        Iterator<?> o = yaml.loadAll("'1\n'--- '2'\n--- '3'").iterator();

        while (o.hasNext()) {
            System.out.println(o.next());
        }

========== Output from sample code ==========

dumpAll strings:
'1'
--- '2'
--- '3'

1 
Exception in thread "main" expected '<document start>', but found Scalar
 in 'reader', line 2, column 2:
    '--- '2'
     ^

Original issue reported on code.google.com by ehuan...@gmail.com on 24 Aug 2013 at 1:41

GoogleCodeExporter commented 9 years ago
The line with:

"'1\n'--- '2'\n--- '3'"

should become

"'1'\n--- '2'\n--- '3'"

Or just pass your 'output' instance to the input.

Original comment by py4fun@gmail.com on 25 Aug 2013 at 6:47

GoogleCodeExporter commented 9 years ago
If you still think this is bug, please create another issue (with a valid use 
case)

Original comment by py4fun@gmail.com on 26 Aug 2013 at 8:53

GoogleCodeExporter commented 9 years ago
you were right! working now after making modification to input. thanks!

Original comment by ehuan...@gmail.com on 26 Aug 2013 at 6:25