public class ReplaceDOMNormalizerSerializerAbortException extends Object implements PreClassLoaderInitiator, ClassLoaderPreMortemCleanUp
DocumentBuilderFactory.newInstance().newDocumentBuilder().newDocument().normalizeDocument(); or
Document document = DocumentBuilderFactory.newInstance().newDocumentBuilder().newDocument();
DOMImplementationLS implementation = (DOMImplementationLS)document.getImplementation();
implementation.createLSSerializer().writeToString(document);
may trigger leaks caused by the static fields com.sun.org.apache.xerces.internal.dom.DOMNormalizer#abort and
com.sun.org.apache.xml.internal.serialize.DOMSerializerImpl#abort respectively keeping stacktraces/backtraces
that may include references to classes loaded by our web application.
Since the Throwable.backtrace itself cannot be accessed via reflection (see
http://bugs.java.com/view_bug.do?bug_id=4496456) we need to replace the with new one without any stack trace.
This can be done either as a PreClassLoaderInitiator (recommended) or ClassLoaderPreMortemCleanUp.| Constructor and Description |
|---|
ReplaceDOMNormalizerSerializerAbortException() |
| Modifier and Type | Method and Description |
|---|---|
void |
cleanUp(ClassLoaderLeakPreventor preventor)
Perform cleanup actions needed to make provided
ClassLoaderLeakPreventor.classLoader
ready for garbage collection. |
static RuntimeException |
constructRuntimeExceptionWithoutStackTrace(ClassLoaderLeakPreventor preventor,
String message,
Throwable cause)
Construct a new
RuntimeException without any stack trace, in order to avoid any references back to this class |
void |
doOutsideClassLoader(ClassLoaderLeakPreventor preventor)
Perform action that needs to be done outside the leak susceptible classloader, i.e. in the system or other parent
classloader.
|
protected void |
replaceDOMNormalizerSerializerAbortException(ClassLoaderLeakPreventor preventor) |
public ReplaceDOMNormalizerSerializerAbortException()
public void doOutsideClassLoader(ClassLoaderLeakPreventor preventor)
PreClassLoaderInitiatorThread.contextClassLoader of the current
thread when method is invoked.
Must NOT have modified Thread.contextClassLoader of the current thread when returning.doOutsideClassLoader in interface PreClassLoaderInitiatorpublic void cleanUp(ClassLoaderLeakPreventor preventor)
ClassLoaderPreMortemCleanUpClassLoaderLeakPreventor.classLoader
ready for garbage collection.cleanUp in interface ClassLoaderPreMortemCleanUpprotected void replaceDOMNormalizerSerializerAbortException(ClassLoaderLeakPreventor preventor)
public static RuntimeException constructRuntimeExceptionWithoutStackTrace(ClassLoaderLeakPreventor preventor, String message, Throwable cause)
RuntimeException without any stack trace, in order to avoid any references back to this classCopyright © 2019. All rights reserved.