Skip to content

Commit

Permalink
Avoid memory leak when thread is reused (#1136)
Browse files Browse the repository at this point in the history
This leak can happen if multiple copies of `smallrye-config` are loaded by different class loaders, like in Quarkus dev mode.
  • Loading branch information
dmlloyd authored Mar 18, 2024
1 parent daaa5b8 commit 2945e03
Showing 1 changed file with 6 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
}
}

Expand All @@ -52,8 +55,8 @@ void increment() {
count = old + 1;
}

void decrement() {
count--;
boolean decrement() {
return --count == 0;
}
}
}

0 comments on commit 2945e03

Please sign in to comment.