ditto icon indicating copy to clipboard operation
ditto copied to clipboard

ConfigWithFallback breaks contract of AbstractConfigValue.withFallback

Open yufei-cai opened this issue 6 years ago • 0 comments

Reproducer:

ConfigFactory.empty()
        .withFallback(
                ConfigWithFallback.newInstance(
                        ConfigFactory.empty(), "x", new KnownConfigValue[0]));

Expected behavior: An empty config object.

Actual behavior: ClassCastException thrown.

java.lang.ClassCastException: org.eclipse.ditto.services.utils.config.ConfigWithFallback cannot be cast to com.typesafe.config.impl.MergeableValue

	at com.typesafe.config.impl.AbstractConfigValue.withFallback(AbstractConfigValue.java:274)
	at com.typesafe.config.impl.AbstractConfigObject.withFallback(AbstractConfigObject.java:139)
	at com.typesafe.config.impl.SimpleConfig.withFallback(SimpleConfig.java:569)
	at com.typesafe.config.impl.SimpleConfig.withFallback(SimpleConfig.java:41)

Workaround: Render the ConfigWithFallback and parse it again.

Proposal: Move fallback values from Java code to .conf files for better documentation; ConfigWithFallback would become unnecessary.

yufei-cai avatar Jul 09 '19 10:07 yufei-cai