Skip to content

Commit

Permalink
Some minor code consolidation
Browse files Browse the repository at this point in the history
  • Loading branch information
coheigea committed May 10, 2019
1 parent e5ebac1 commit 2be435c
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 17 deletions.
26 changes: 13 additions & 13 deletions core/src/main/java/org/apache/cxf/helpers/DOMUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -84,9 +84,9 @@ protected Method computeValue(Class<?> type) {
protected Field computeValue(Class<?> type) {
return ReflectionUtil.getDeclaredField(type, "documentFragment");
}

};

static {
try {
Method[] methods = DOMUtils.class.getClassLoader().
Expand Down Expand Up @@ -131,24 +131,24 @@ private static DocumentBuilder getDocumentBuilder() throws ParserConfigurationEx
loader = getClassLoader(DOMUtils.class);
}
if (loader == null) {
DocumentBuilderFactory f = DocumentBuilderFactory.newInstance();
f.setNamespaceAware(true);
f.setFeature(javax.xml.XMLConstants.FEATURE_SECURE_PROCESSING, true);
f.setFeature("http://apache.org/xml/features/disallow-doctype-decl", true);
return f.newDocumentBuilder();
return createDocumentBuilder();
}
DocumentBuilder factory = DOCUMENT_BUILDERS.get(loader);
if (factory == null) {
DocumentBuilderFactory f2 = DocumentBuilderFactory.newInstance();
f2.setNamespaceAware(true);
f2.setFeature(javax.xml.XMLConstants.FEATURE_SECURE_PROCESSING, true);
f2.setFeature("http://apache.org/xml/features/disallow-doctype-decl", true);
factory = f2.newDocumentBuilder();
factory = createDocumentBuilder();
DOCUMENT_BUILDERS.put(loader, factory);
}
return factory;
}

private static DocumentBuilder createDocumentBuilder() throws ParserConfigurationException {
DocumentBuilderFactory f = DocumentBuilderFactory.newInstance();
f.setNamespaceAware(true);
f.setFeature(javax.xml.XMLConstants.FEATURE_SECURE_PROCESSING, true);
f.setFeature("http://apache.org/xml/features/disallow-doctype-decl", true);
return f.newDocumentBuilder();
}

private static ClassLoader getContextClassLoader() {
final SecurityManager sm = System.getSecurityManager();
if (sm != null) {
Expand Down Expand Up @@ -781,7 +781,7 @@ public static Node getDomElement(Node node) {
}
return node;
}

/**
* Try to get the DOM DocumentFragment from the SAAJ DocumentFragment with JAVA9 afterwards
* @param DocumentFragment The original documentFragment we need check
Expand Down
8 changes: 4 additions & 4 deletions core/src/main/java/org/apache/cxf/staxutils/StaxUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@
import java.util.Deque;
import java.util.Iterator;
import java.util.List;
import java.util.Queue;
import java.util.concurrent.ArrayBlockingQueue;
import java.util.concurrent.BlockingQueue;
import java.util.logging.Level;
import java.util.logging.Logger;

Expand Down Expand Up @@ -125,9 +125,9 @@ public final class StaxUtils {

private static final Logger LOG = LogUtils.getL7dLogger(StaxUtils.class);

private static final BlockingQueue<XMLInputFactory> NS_AWARE_INPUT_FACTORY_POOL;
private static final Queue<XMLInputFactory> NS_AWARE_INPUT_FACTORY_POOL;
private static final XMLInputFactory SAFE_INPUT_FACTORY;
private static final BlockingQueue<XMLOutputFactory> OUTPUT_FACTORY_POOL;
private static final Queue<XMLOutputFactory> OUTPUT_FACTORY_POOL;
private static final XMLOutputFactory SAFE_OUTPUT_FACTORY;

private static final String XML_NS = "http://www.w3.org/2000/xmlns/";
Expand Down Expand Up @@ -706,7 +706,7 @@ public static void writeTo(Node node, Writer os, int indent) throws XMLStreamExc

/**
* Copies the reader to the writer. The start and end document methods must
* be handled on the writer manually.
* be handled on the writer manually.
*
* @param reader
* @param writer
Expand Down

0 comments on commit 2be435c

Please sign in to comment.