diqiu50 opened a new pull request, #12925: URL: https://github.com/apache/gravitino/pull/12925
### What changes were proposed in this pull request? Override `HiveClientClassLoader#close()` to shut down the Log4j `LoggerContext` associated with this classloader before closing its jar handles. ### Why are the changes needed? When a barrier class defined by `HiveClientClassLoader` (e.g. `Util`, `HiveClientImpl`, `HiveShim`) first logs, log4j-slf4j2-impl's `Log4jLoggerFactory` registers a `LoggerContext` keyed by that class's defining classloader and keeps a strong reference to it in its internal registry. Since `close()` never released that context, the classloader stayed strongly reachable through Log4j even after `close()`, leaking Metaspace on every Hive client-pool eviction/recreation cycle (reported after ~12 days of uptime with periodic Hive catalog access). Fixes #12246 ### Does this PR introduce any user-facing change? No. ### How was this patch tested? Added `TestHiveClientClassLoader#testCloseRemovesLog4jLoggerContextRegistration`, which triggers a barrier class to log (registering a `LoggerContext`), then asserts the `Log4jLoggerFactory` registry entry is removed after `close()`. Verified the test fails without the fix and passes with it. Ran the full `hive-metastore-common` test module — all pass. 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_01Kqa6kk4Wkdt9VC6s5Znipo -- 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]
