NullPointerException occurs when reading a YAML with no value in the master branch.
(example)
item:
name: foo
price: 100
description:
"description" has no value.
Exception in thread "main" java.lang.NullPointerException
at java.lang.Integer.decode(Integer.java:1161)
at com.esotericsoftware.yamlbeans.YamlReader.readValueInternal(YamlReader.java:206)
at com.esotericsoftware.yamlbeans.YamlReader.readValue(YamlReader.java:138)
at com.esotericsoftware.yamlbeans.YamlReader.readValueInternal(YamlReader.java:351)
at com.esotericsoftware.yamlbeans.YamlReader.readValue(YamlReader.java:138)
at com.esotericsoftware.yamlbeans.YamlReader.readValueInternal(YamlReader.java:351)
at com.esotericsoftware.yamlbeans.YamlReader.readValue(YamlReader.java:138)
at com.esotericsoftware.yamlbeans.YamlReader.readValueInternal(YamlReader.java:351)
at com.esotericsoftware.yamlbeans.YamlReader.readValue(YamlReader.java:138)
at com.esotericsoftware.yamlbeans.YamlReader.read(YamlReader.java:105)
at com.esotericsoftware.yamlbeans.YamlReader.read(YamlReader.java:92)
at com.esotericsoftware.yamlbeans.YamlReader.read(YamlReader.java:86)
--- yamlbeans-master\src\com\esotericsoftware\yamlbeans\YamlReader.java 2017-11-08 21:03:59.000000000 +0900
+++ yamlbeans-fixed\src\com\esotericsoftware\yamlbeans\YamlReader.java 2017-11-16 01:38:12.342209100 +0900
@@ -202,17 +202,19 @@
case SCALAR:
if (config.readConfig.guessNumberTypes) {
String value = ((ScalarEvent)event).value;
- try {
- Integer convertedValue = Integer.decode(value);
- if (anchor != null) anchors.put(anchor, convertedValue);
- return convertedValue;
- } catch (NumberFormatException ex) {
- }
- try {
- Float convertedValue = Float.valueOf(value);
- if (anchor != null) anchors.put(anchor, convertedValue);
- return convertedValue;
- } catch (NumberFormatException ex) {
+ if(value != null) {
+ try {
+ Integer convertedValue = Integer.decode(value);
+ if (anchor != null) anchors.put(anchor, convertedValue);
+ return convertedValue;
+ } catch (NumberFormatException ex) {
+ }
+ try {
+ Float convertedValue = Float.valueOf(value);
+ if (anchor != null) anchors.put(anchor, convertedValue);
+ return convertedValue;
+ } catch (NumberFormatException ex) {
+ }
}
}
type = String.class;