NPE in DuplicateKeyException constructor
We've hit a NPE in when constructing a DuplicateKeyException
The call stack is:
File DuplicateKeyException.java line 24 in org.yaml.snakeyaml.constructor.DuplicateKeyException.<init>
File SafeConstructor.java line 100 in org.yaml.snakeyaml.constructor.SafeConstructor.processDuplicateKeys
File SafeConstructor.java line 70 in org.yaml.snakeyaml.constructor.SafeConstructor.flattenMapping
File SafeConstructor.java line 183 in org.yaml.snakeyaml.constructor.SafeConstructor.constructMapping2ndStep
File BaseConstructor.java line 434 in org.yaml.snakeyaml.constructor.BaseConstructor.constructMapping
File SafeConstructor.java line 521 in org.yaml.snakeyaml.constructor.SafeConstructor$ConstructYamlMap.construct
File BaseConstructor.java line 204 in org.yaml.snakeyaml.constructor.BaseConstructor.constructObjectNoCheck
File BaseConstructor.java line 193 in org.yaml.snakeyaml.constructor.BaseConstructor.constructObject
File BaseConstructor.java line 159 in org.yaml.snakeyaml.constructor.BaseConstructor.constructDocument
File BaseConstructor.java line 146 in org.yaml.snakeyaml.constructor.BaseConstructor.getSingleData
File Yaml.java line 524 in org.yaml.snakeyaml.Yaml.loadFromReader
File Yaml.java line 437 in org.yaml.snakeyaml.Yaml.load
Using org.yaml/snakeyaml
1.23
.
I've not tried to debug the issue yet - step 1 I wanted to log the bug.
Our internal URL to track this at CircleCI is https://rollbar.com/circle/orb-service/items/116/ (logging this for our own reference).
I'll try to get the offending YAML document, I don't have it available at present.
Comments (7)
-
reporter -
- changed status to open
I will have a look.
-
reporter Thanks Andrey.
This should fix it:
public class DuplicateKeyException extends ConstructorException { protected DuplicateKeyException(Mark contextMark, Object key, Mark problemMark) { super("while constructing a mapping", contextMark, "found duplicate key " + String.valueOf(key), problemMark); } }
-
reporter My Yaml is being parsed using the following loader (from Clojure):
(defn strict-loader-options ^LoaderOptions [] (doto (LoaderOptions.) (.setAllowDuplicateKeys false))) (defn strict-loader ^Yaml [] (Yaml. (SafeConstructor.) (Representer.) (DumperOptions.) (strict-loader-options)))
-
- changed status to resolved
Thank you very much.
Your fix will be delivered in version 1.24 (https://bitbucket.org/asomov/snakeyaml/wiki/Changes)
-
reporter Thank you Andrey (and thank you for all the time that you spend on this library).
Will you be able to publish the new version soon? I see that you try to release twice a year – and the next release is due in February). Will you be able to publish a new jar before then?
Marc
-
Dear Marc, the code has production quality if the tests are green. You can build it with your own classifier and upload to a repository for internal usage.
You can also take the latest snapshot: https://bitbucket.org/asomov/snakeyaml/wiki/Installation
- Log in to comment
Here is an example that fails:
This throws: