paradigmatic / Configrity

Simple, immutable and flexible configuration library for scala.
Other
132 stars 19 forks source link

Empty sections in YAML config cause NullPointerExceptions #23

Closed fxkr closed 10 years ago

fxkr commented 11 years ago

Valid YAML file:

mixer:

hardware:
    device: "/dev/ttyUSB0"

Code to load it:

Configuration.load("config.yaml", YAMLFormat)

Traceback:

Exception in thread "main" java.lang.NullPointerException
    at org.streum.configrity.yaml.YAMLFormat$.org$streum$configrity$yaml$YAMLFormat$$readValue(YAMLFormat.scala:70)
    at org.streum.configrity.yaml.YAMLFormat$$anonfun$readMap$1.apply(YAMLFormat.scala:62)
    at org.streum.configrity.yaml.YAMLFormat$$anonfun$readMap$1.apply(YAMLFormat.scala:61)
    at scala.collection.TraversableOnce$$anonfun$foldLeft$1.apply(TraversableOnce.scala:144)
    at scala.collection.TraversableOnce$$anonfun$foldLeft$1.apply(TraversableOnce.scala:144)
    at scala.collection.immutable.Map$Map3.foreach(Map.scala:154)
    at scala.collection.TraversableOnce$class.foldLeft(TraversableOnce.scala:144)
    at scala.collection.AbstractTraversable.foldLeft(Traversable.scala:105)
    at org.streum.configrity.yaml.YAMLFormat$.readMap(YAMLFormat.scala:61)
    at org.streum.configrity.yaml.YAMLFormat$.yaml2map(YAMLFormat.scala:52)
    at org.streum.configrity.yaml.YAMLFormat$.fromText(YAMLFormat.scala:34)
    at org.streum.configrity.Configuration$.load(Configuration.scala:231)
    at org.streum.configrity.Configuration$.load(Configuration.scala:246)
    at my.code.Blub$.load(Config.scala:132)
paradigmatic commented 10 years ago

I have some time left to improve Configrity. Sorry for the long delay. I will try to fix this bug very soon.

paradigmatic commented 10 years ago

Bug is fixed in last commit. In YAML parsing, any key with an empty value will be ignored.