From decadc0476b57ac8ac1082847f33f1f2c9d9b244 Mon Sep 17 00:00:00 2001 From: Henrik Nordvik Date: Mon, 9 Mar 2020 16:17:00 -0700 Subject: [PATCH] Fix resolution of references Resolve failed with the following exception when using references: Exception in thread "main" com.typesafe.config.ConfigException$BugOrBroken: replace in parent not possible The docs for resolveWith says: > Note that this method does NOT look in this instance for substitution values. Which means we can't refer to variabled in the same config. It also says: > If you want to do that, you could either merge this instance into > your value source using Config.withFallback, or you could resolve > multiple times with multiple sources (using setAllowUnresolved). I tried using withFallback, but the same error still occurred. This might be due to a bug in typesafe config: https://github.com/lightbend/config/issues/332 This works around that by resolving multiple times as suggested in the javadoc. --- src/main/java/com/github/okapies/hoc2js/Hoc2Js.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main/java/com/github/okapies/hoc2js/Hoc2Js.java b/src/main/java/com/github/okapies/hoc2js/Hoc2Js.java index deb8b65..03cf0d2 100644 --- a/src/main/java/com/github/okapies/hoc2js/Hoc2Js.java +++ b/src/main/java/com/github/okapies/hoc2js/Hoc2Js.java @@ -30,6 +30,7 @@ public static void main(String[] args) { // resolve ConfigResolveOptions resolveOpts = loadResolveOpts(config); + obj = obj.resolve(resolveOpts.setAllowUnresolved(true)); obj = obj.resolveWith(config, resolveOpts); // render