From 4739cba0bd44f16a63d77a234efb9a5c72ebf520 Mon Sep 17 00:00:00 2001 From: Havoc Pennington Date: Fri, 24 Jul 2020 11:20:07 -0400 Subject: [PATCH] Remove unmodifiable collection wrappers in ResolveContext This fixes #700 (Java is unhelpful and the Collections.unmodifiableList etc methods don't check whether the thing is already wrapped). These were just an assertion basically intended to find any accidental modification of these collections, so not essential. --- .../java/com/typesafe/config/impl/ResolveContext.java | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/config/src/main/java/com/typesafe/config/impl/ResolveContext.java b/config/src/main/java/com/typesafe/config/impl/ResolveContext.java index cf669912f..bb59af94a 100644 --- a/config/src/main/java/com/typesafe/config/impl/ResolveContext.java +++ b/config/src/main/java/com/typesafe/config/impl/ResolveContext.java @@ -32,8 +32,12 @@ final class ResolveContext { this.memos = memos; this.options = options; this.restrictToChild = restrictToChild; - this.resolveStack = Collections.unmodifiableList(resolveStack); - this.cycleMarkers = Collections.unmodifiableSet(cycleMarkers); + // we don't defensively copy/wrap these because Collections.unmodifiableList etc. + // nest infinitely in a way that causes stack overflow (they don't check to avoid + // multiple wrappers). But they should be treated as immutable because they end + // up shared between multiple ResolveContext. + this.resolveStack = resolveStack; + this.cycleMarkers = cycleMarkers; } private static Set newCycleMarkers() {