Aias00 opened a new issue, #6856: URL: https://github.com/apache/shenyu/issues/6856
## Description `PROXY_CACHE` is a `static` `ConcurrentMap<Class<?>, Object>` that is never cleared. `createProxy` does a `containsKey`-then-`get` fast path, else `synchronized(apiClass)` builds a `ShenyuClientInvocationHandler` (which captures the `ApplicationContext` and the per-bean `ShenyuClientFactoryBean` and resolves `applicationContext.getBean(ShenyuSdkClient.class)` at construction) and stores it in the static map. The first `ApplicationContext` to build a proxy for a given interface wins; every subsequent context (Spring Boot devtools restart, repeated `@SpringBootTest` contexts) receives the cached proxy bound to the now-closed previous context. ## Location - `shenyu-sdk/shenyu-sdk-spring/src/main/java/org/apache/shenyu/sdk/spring/proxy/ShenyuClientProxyFactory.java:36,51-61` - `shenyu-sdk/shenyu-sdk-spring/src/main/java/org/apache/shenyu/sdk/spring/proxy/ShenyuClientInvocationHandler.java:65-74,99-114` ## Impact After a context restart the proxy's captured `ShenyuSdkClient` and `ApplicationContext` belong to the dead context (broken/leaked HTTP client, stale url/path from the old `ShenyuClientFactoryBean`). The static cache also holds a strong reference to the closed `ApplicationContext` and all beans it transitively captured, preventing GC of closed contexts → memory growth across restarts. ## Suggested fix Key the cache per-context (or drop the static cache and rely on `FactoryBean.isSingleton()` + Spring's own singleton cache); alternatively clear `PROXY_CACHE` on context close / make it an instance field wired to the registrar. ## Related existing None — distinct from #6787 (static URIS list in register-client `ShenyuClientURIExecutorSubscriber`, different class/module) and #6729 (GW-SPI-7, ExtensionLoader pinned ClassLoader). -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
