8146961: Fix PermGen memory leaks caused by static final Exceptions
Reviewed-by: joehw, shade, clanger, plevart
This commit is contained in:
parent
a45449a1e4
commit
df25ab9597
jaxp/src/java.xml/share/classes/com/sun/org/apache
xerces/internal/dom
xml/internal/serialize
36
jaxp/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/dom/AbortException.java
Normal file
36
jaxp/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/dom/AbortException.java
Normal file
@ -0,0 +1,36 @@
|
||||
/*
|
||||
* Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package com.sun.org.apache.xerces.internal.dom;
|
||||
|
||||
public class AbortException extends RuntimeException {
|
||||
|
||||
private static final long serialVersionUID = 2608302175475740417L;
|
||||
|
||||
/**
|
||||
* Constructor AbortException
|
||||
*/
|
||||
public AbortException() { super(null, null, false, false); }
|
||||
}
|
@ -26,6 +26,7 @@ import java.util.ArrayList;
|
||||
import java.io.StringReader;
|
||||
import java.util.Vector;
|
||||
|
||||
import com.sun.org.apache.xerces.internal.dom.AbortException;
|
||||
import com.sun.org.apache.xerces.internal.impl.Constants;
|
||||
import com.sun.org.apache.xerces.internal.impl.RevalidationHandler;
|
||||
import com.sun.org.apache.xerces.internal.impl.dtd.DTDGrammar;
|
||||
@ -157,11 +158,6 @@ public class DOMNormalizer implements XMLDocumentHandler {
|
||||
// attribute value normalization
|
||||
final XMLString fNormalizedValue = new XMLString(new char[16], 0, 0);
|
||||
|
||||
/**
|
||||
* If the user stops the process, this exception will be thrown.
|
||||
*/
|
||||
public static final RuntimeException abort = new RuntimeException();
|
||||
|
||||
//DTD validator
|
||||
private XMLDTDValidator fDTDValidator;
|
||||
|
||||
@ -242,11 +238,8 @@ public class DOMNormalizer implements XMLDocumentHandler {
|
||||
XMLGrammarDescription.XML_SCHEMA, fValidationHandler);
|
||||
fValidationHandler = null;
|
||||
}
|
||||
}
|
||||
catch (RuntimeException e) {
|
||||
if( e==abort )
|
||||
return; // processing aborted by the user
|
||||
throw e; // otherwise re-throw.
|
||||
} catch (AbortException e) {
|
||||
return;
|
||||
}
|
||||
|
||||
}
|
||||
@ -1371,10 +1364,10 @@ public class DOMNormalizer implements XMLDocumentHandler {
|
||||
error.fRelatedData = locator.fRelatedNode;
|
||||
|
||||
if(!errorHandler.handleError(error))
|
||||
throw abort;
|
||||
throw new AbortException();
|
||||
}
|
||||
if( severity==DOMError.SEVERITY_FATAL_ERROR )
|
||||
throw abort;
|
||||
throw new AbortException();
|
||||
}
|
||||
|
||||
protected final void updateQName (Node node, QName qname){
|
||||
@ -2043,5 +2036,4 @@ public class DOMNormalizer implements XMLDocumentHandler {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
} // DOMNormalizer class
|
||||
|
@ -28,6 +28,7 @@ import java.io.Writer;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.ArrayList;
|
||||
|
||||
import com.sun.org.apache.xerces.internal.dom.AbortException;
|
||||
import com.sun.org.apache.xerces.internal.dom.CoreDocumentImpl;
|
||||
import com.sun.org.apache.xerces.internal.dom.DOMErrorImpl;
|
||||
import com.sun.org.apache.xerces.internal.dom.DOMLocatorImpl;
|
||||
@ -501,11 +502,9 @@ public class DOMSerializerImpl implements LSSerializer, DOMConfiguration {
|
||||
} catch (LSException lse) {
|
||||
// Rethrow LSException.
|
||||
throw lse;
|
||||
} catch (AbortException e) {
|
||||
return null;
|
||||
} catch (RuntimeException e) {
|
||||
if (e == DOMNormalizer.abort) {
|
||||
// stopped at user request
|
||||
return null;
|
||||
}
|
||||
throw (LSException) DOMUtil.createLSException(LSException.SERIALIZE_ERR, e).fillInStackTrace();
|
||||
} catch (IOException ioe) {
|
||||
// REVISIT: A generic IOException doesn't provide enough information
|
||||
@ -733,11 +732,9 @@ public class DOMSerializerImpl implements LSSerializer, DOMConfiguration {
|
||||
} catch (LSException lse) {
|
||||
// Rethrow LSException.
|
||||
throw lse;
|
||||
} catch (AbortException e) {
|
||||
return false;
|
||||
} catch (RuntimeException e) {
|
||||
if (e == DOMNormalizer.abort) {
|
||||
// stopped at user request
|
||||
return false;
|
||||
}
|
||||
throw (LSException) DOMUtil.createLSException(LSException.SERIALIZE_ERR, e).fillInStackTrace();
|
||||
} catch (Exception e) {
|
||||
if (ser.fDOMErrorHandler != null) {
|
||||
@ -833,11 +830,9 @@ public class DOMSerializerImpl implements LSSerializer, DOMConfiguration {
|
||||
} catch (LSException lse) {
|
||||
// Rethrow LSException.
|
||||
throw lse;
|
||||
} catch (AbortException e) {
|
||||
return false;
|
||||
} catch (RuntimeException e) {
|
||||
if (e == DOMNormalizer.abort) {
|
||||
// stopped at user request
|
||||
return false;
|
||||
}
|
||||
throw (LSException) DOMUtil.createLSException(LSException.SERIALIZE_ERR, e).fillInStackTrace();
|
||||
} catch (Exception e) {
|
||||
if (ser.fDOMErrorHandler != null) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user