a pitfall in typesafe config

Posted by CodingCat on November 24, 2014

Actually this is explicitly stated in the Java docs: http://typesafehub.github.io/config/latest/api/, just didn’t get my attention (and I think the description there is not that clear)

The withFallback API will stop going further when you pass a non-object as the parameter,


in object.withFallback(nonObject).withFallback(otherObject), where nonObject is String/Integer, otherObject is just ignored silently

The reason is that in Typesafe Config Lib, the nonObject always priorities over the object ones,

Additionally, in withFallBack, the values are “merged” instead of  ”overwritten” when certain key has more than one occurrence are involved, i.e.

(1) (10 can be any non-object value)

foo = object

foo = 10

-> then foo == 10


foo = object1

foo = object2

-> then foo = [object1, object2]

(3) (10, 20 can also be any non-object value)



-> then foo=20