reta commented on code in PR #2582:
URL: https://github.com/apache/cxf/pull/2582#discussion_r2323728661
##########
core/src/main/java/org/apache/cxf/common/logging/JDKBugHacks.java:
##########
@@ -99,91 +96,61 @@ public static void doHacks() {
.setThreadContextClassloader(ClassLoader.getSystemClassLoader());
try {
try {
- //Trigger a call to sun.awt.AppContext.getAppContext()
+ /*
+ * Several components end up calling:
sun.awt.AppContext.getAppContext()
+ *
+ * Those libraries / components known to trigger memory
leaks due to eventual calls to
+ * getAppContext() are:
+ * - Google Web Toolkit via its use of javax.imageio
+ * - Batik
+ * - others TBD
+ *
+ * Note that a call to sun.awt.AppContext.getAppContext()
results in a thread being started named
+ * AWT-AppKit that requires a graphical environment to be
available.
+ */
+
+ // Trigger a call to sun.awt.AppContext.getAppContext().
This
+ // will pin the system class loader in memory but that
shouldn't
+ // be an issue.
if (!skipHack("org.apache.cxf.JDKBugHacks.imageIO",
"true")) {
ImageIO.getCacheDirectory();
}
} catch (Throwable t) {
//ignore
}
- try {
- //DocumentBuilderFactory seems to SOMETIMES pin the
classloader
- if
(!skipHack("org.apache.cxf.JDKBugHacks.documentBuilderFactory")) {
- DocumentBuilderFactory factory =
DocumentBuilderFactory.newInstance();
- factory.newDocumentBuilder();
- }
- } catch (Throwable e) {
- //ignore
- }
- // Several components end up calling:
- // sun.misc.GC.requestLatency(long)
- //
- // Those libraries / components known to trigger memory leaks
due to
- // eventual calls to requestLatency(long) are:
- // - javax.management.remote.rmi.RMIConnectorServer.start()
- try {
- if
(!skipHack("org.apache.cxf.JDKBugHacks.gcRequestLatency")) {
- Class<?> clazz = Class.forName("sun.misc.GC");
- Method method =
clazz.getDeclaredMethod("currentLatencyTarget");
- Long l = (Long)method.invoke(null);
- if (l != null && l.longValue() == 0) {
- //something already set it, move on
- method = clazz.getDeclaredMethod("requestLatency",
Long.TYPE);
- method.invoke(null, Long.valueOf(36000000));
- }
- }
- } catch (Throwable e) {
- //ignore
- }
- // Calling getPolicy retains a static reference to the context
- // class loader.
try {
- // Policy.getPolicy();
- if (!skipHack("org.apache.cxf.JDKBugHacks.policy")) {
- Class<?> policyClass = Class
- .forName("javax.security.auth.Policy");
- Method method = policyClass.getMethod("getPolicy");
- method.invoke(null);
- }
- } catch (Throwable e) {
- // ignore
- }
- try {
- // Initializing javax.security.auth.login.Configuration
retains a static reference
- // to the context class loader.
- if
(!skipHack("org.apache.cxf.JDKBugHacks.authConfiguration")) {
Review Comment:
`javax.security.auth.login.Configuration` seems to be present in JDK-21,
could you please keep it?
--
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]