diff --git a/implementation/src/main/java/io/smallrye/config/SmallRyeConfigSourceInterceptorContext.java b/implementation/src/main/java/io/smallrye/config/SmallRyeConfigSourceInterceptorContext.java index 95bae8da1..6643fa804 100644 --- a/implementation/src/main/java/io/smallrye/config/SmallRyeConfigSourceInterceptorContext.java +++ b/implementation/src/main/java/io/smallrye/config/SmallRyeConfigSourceInterceptorContext.java @@ -32,7 +32,10 @@ public ConfigValue restart(final String name) { try { return config.interceptorChain().proceed(name); } finally { - rc.decrement(); + if (rc.decrement()) { + // avoid leaking if the thread is cached + rcHolder.remove(); + } } } @@ -52,8 +55,8 @@ void increment() { count = old + 1; } - void decrement() { - count--; + boolean decrement() { + return --count == 0; } } }