-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #35282 from gsmet/cleanup-bytecode-recorders
Avoid keeping references to BytecodeRecorderImpl
- Loading branch information
Showing
2 changed files
with
37 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30 changes: 30 additions & 0 deletions
30
core/deployment/src/main/java/io/quarkus/deployment/recording/RecordingProxyFactories.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
package io.quarkus.deployment.recording; | ||
|
||
import java.util.Map; | ||
import java.util.concurrent.ConcurrentHashMap; | ||
|
||
import io.quarkus.bootstrap.classloading.QuarkusClassLoader; | ||
import io.quarkus.deployment.proxy.ProxyFactory; | ||
|
||
class RecordingProxyFactories { | ||
|
||
private static final Map<Class<?>, ProxyFactory<?>> RECORDING_PROXY_FACTORIES = new ConcurrentHashMap<>(); | ||
|
||
static <T> void put(Class<T> clazz, ProxyFactory<T> proxyFactory) { | ||
RECORDING_PROXY_FACTORIES.put(clazz, proxyFactory); | ||
|
||
if (clazz.getClassLoader() instanceof QuarkusClassLoader) { | ||
((QuarkusClassLoader) clazz.getClassLoader()).addCloseTask(new Runnable() { | ||
@Override | ||
public void run() { | ||
RecordingProxyFactories.RECORDING_PROXY_FACTORIES.remove(clazz); | ||
} | ||
}); | ||
} | ||
} | ||
|
||
@SuppressWarnings("unchecked") | ||
static <T> ProxyFactory<T> get(Class<T> clazz) { | ||
return (ProxyFactory<T>) RECORDING_PROXY_FACTORIES.get(clazz); | ||
} | ||
} |