You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by da...@apache.org on 2014/03/18 16:57:40 UTC
[1/3] git commit: CAMEL-7309: Reduce excessive INFO logging if using
stax converter with woodstox on classpath.
Repository: camel
Updated Branches:
refs/heads/camel-2.12.x b83f0b6d9 -> db612f54e
refs/heads/camel-2.13.x 65a58710c -> c6b37c45d
refs/heads/master fa165d6b9 -> fcd2accf2
CAMEL-7309: Reduce excessive INFO logging if using stax converter with woodstox on classpath.
Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/fcd2accf
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/fcd2accf
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/fcd2accf
Branch: refs/heads/master
Commit: fcd2accf2d9417531a19bd0d6527b60001b83f6a
Parents: fa165d6
Author: Claus Ibsen <da...@apache.org>
Authored: Tue Mar 18 16:59:59 2014 +0100
Committer: Claus Ibsen <da...@apache.org>
Committed: Tue Mar 18 16:59:59 2014 +0100
----------------------------------------------------------------------
.../camel/converter/jaxp/StaxConverter.java | 53 +++++++++-----------
1 file changed, 24 insertions(+), 29 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/camel/blob/fcd2accf/camel-core/src/main/java/org/apache/camel/converter/jaxp/StaxConverter.java
----------------------------------------------------------------------
diff --git a/camel-core/src/main/java/org/apache/camel/converter/jaxp/StaxConverter.java b/camel-core/src/main/java/org/apache/camel/converter/jaxp/StaxConverter.java
index ca16a11..6a908e6 100644
--- a/camel-core/src/main/java/org/apache/camel/converter/jaxp/StaxConverter.java
+++ b/camel-core/src/main/java/org/apache/camel/converter/jaxp/StaxConverter.java
@@ -32,8 +32,6 @@ import javax.xml.stream.XMLStreamReader;
import javax.xml.stream.XMLStreamWriter;
import javax.xml.transform.Result;
import javax.xml.transform.Source;
-import javax.xml.transform.dom.DOMResult;
-import javax.xml.transform.dom.DOMSource;
import org.apache.camel.Converter;
import org.apache.camel.Exchange;
@@ -48,10 +46,8 @@ import org.slf4j.LoggerFactory;
*/
@Converter
public class StaxConverter {
- private static final Logger LOG = LoggerFactory.getLogger(XmlErrorListener.class);
+ private static final Logger LOG = LoggerFactory.getLogger(StaxConverter.class);
- // TODO: do not use a cxf system property
- // TODO: make higher default pool size as 20 is not much in high end systems
private static final BlockingQueue<XMLInputFactory> INPUT_FACTORY_POOL;
private static final BlockingQueue<XMLOutputFactory> OUTPUT_FACTORY_POOL;
static {
@@ -68,9 +64,23 @@ public class StaxConverter {
//ignore
i = 20;
}
+ try {
+ // if we have more cores than 20, then use that
+ int cores = Runtime.getRuntime().availableProcessors();
+ if (cores > i) {
+ i = cores;
+ }
+ } catch (Throwable t) {
+ // ignore
+ i = 20;
+ }
+
if (i <= 0) {
i = 20;
}
+
+ LOG.debug("StaxConverter pool size: {}", i);
+
INPUT_FACTORY_POOL = new LinkedBlockingQueue<XMLInputFactory>(i);
OUTPUT_FACTORY_POOL = new LinkedBlockingQueue<XMLOutputFactory>(i);
}
@@ -102,12 +112,6 @@ public class StaxConverter {
public XMLEventWriter createXMLEventWriter(Result result) throws XMLStreamException {
XMLOutputFactory factory = getOutputFactory();
try {
- if (result instanceof DOMResult && !isWoodstox(factory)) {
- //FIXME - if not woodstox, this will likely not work well
- //likely should copy CXF's W3CDOM stuff
- LOG.info("DOMResult is known to have issues with {0}. We suggest using Woodstox",
- factory.getClass());
- }
return factory.createXMLEventWriter(result);
} finally {
returnXMLOutputFactory(factory);
@@ -138,12 +142,6 @@ public class StaxConverter {
public XMLStreamWriter createXMLStreamWriter(Result result) throws XMLStreamException {
XMLOutputFactory factory = getOutputFactory();
try {
- if (result instanceof DOMResult && !isWoodstox(factory)) {
- //FIXME - if not woodstox, this will likely not work well
- //likely should copy CXF's W3CDOM stuff
- LOG.info("DOMResult is known to have issues with {0}. We suggest using Woodstox",
- factory.getClass());
- }
return factory.createXMLStreamWriter(result);
} finally {
returnXMLOutputFactory(factory);
@@ -202,12 +200,6 @@ public class StaxConverter {
public XMLStreamReader createXMLStreamReader(Source in) throws XMLStreamException {
XMLInputFactory factory = getInputFactory();
try {
- if (in instanceof DOMSource && !isWoodstox(factory)) {
- //FIXME - if not woodstox, this will likely not work well
- //likely should copy CXF's W3CDOM stuff
- LOG.info("DOMSource is known to have issues with {0}. We suggest using Woodstox",
- factory.getClass());
- }
return factory.createXMLStreamReader(in);
} finally {
returnXMLInputFactory(factory);
@@ -286,18 +278,13 @@ public class StaxConverter {
public XMLEventReader createXMLEventReader(Source in) throws XMLStreamException {
XMLInputFactory factory = getInputFactory();
try {
- if (in instanceof DOMSource && !isWoodstox(factory)) {
- //FIXME - if not woodstox, this will likely not work well
- LOG.info("DOMSource is known to have issues with {0}. We suggest using Woodstox",
- factory.getClass());
- }
return factory.createXMLEventReader(in);
} finally {
returnXMLInputFactory(factory);
}
}
- private boolean isWoodstox(Object factory) {
+ private static boolean isWoodstox(Object factory) {
return factory.getClass().getPackage().getName().startsWith("com.ctc.wstx");
}
@@ -342,6 +329,14 @@ public class StaxConverter {
throw new XMLStreamException("Reading external entities is disabled");
}
});
+
+ if (isWoodstox(factory)) {
+ // just log a debug as we are good then
+ LOG.debug("Created Woodstox XMLInputFactory: {}", factory);
+ } else {
+ // log a hint that woodstock may be a better factory to use
+ LOG.info("Created XMLInputFactory: {}. DOMSource/DOMResult may have issues with {}. We suggest using Woodstox.", factory, factory);
+ }
return factory;
}
[3/3] git commit: CAMEL-7309: Reduce excessive INFO logging if using
stax converter with woodstox on classpath.
Posted by da...@apache.org.
CAMEL-7309: Reduce excessive INFO logging if using stax converter with woodstox on classpath.
Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/db612f54
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/db612f54
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/db612f54
Branch: refs/heads/camel-2.12.x
Commit: db612f54e9137cdc1c1e6f5b71b85e8c4c6bcb5d
Parents: b83f0b6
Author: Claus Ibsen <da...@apache.org>
Authored: Tue Mar 18 16:59:59 2014 +0100
Committer: Claus Ibsen <da...@apache.org>
Committed: Tue Mar 18 17:00:24 2014 +0100
----------------------------------------------------------------------
.../camel/converter/jaxp/StaxConverter.java | 53 +++++++++-----------
1 file changed, 24 insertions(+), 29 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/camel/blob/db612f54/camel-core/src/main/java/org/apache/camel/converter/jaxp/StaxConverter.java
----------------------------------------------------------------------
diff --git a/camel-core/src/main/java/org/apache/camel/converter/jaxp/StaxConverter.java b/camel-core/src/main/java/org/apache/camel/converter/jaxp/StaxConverter.java
index ca16a11..6a908e6 100644
--- a/camel-core/src/main/java/org/apache/camel/converter/jaxp/StaxConverter.java
+++ b/camel-core/src/main/java/org/apache/camel/converter/jaxp/StaxConverter.java
@@ -32,8 +32,6 @@ import javax.xml.stream.XMLStreamReader;
import javax.xml.stream.XMLStreamWriter;
import javax.xml.transform.Result;
import javax.xml.transform.Source;
-import javax.xml.transform.dom.DOMResult;
-import javax.xml.transform.dom.DOMSource;
import org.apache.camel.Converter;
import org.apache.camel.Exchange;
@@ -48,10 +46,8 @@ import org.slf4j.LoggerFactory;
*/
@Converter
public class StaxConverter {
- private static final Logger LOG = LoggerFactory.getLogger(XmlErrorListener.class);
+ private static final Logger LOG = LoggerFactory.getLogger(StaxConverter.class);
- // TODO: do not use a cxf system property
- // TODO: make higher default pool size as 20 is not much in high end systems
private static final BlockingQueue<XMLInputFactory> INPUT_FACTORY_POOL;
private static final BlockingQueue<XMLOutputFactory> OUTPUT_FACTORY_POOL;
static {
@@ -68,9 +64,23 @@ public class StaxConverter {
//ignore
i = 20;
}
+ try {
+ // if we have more cores than 20, then use that
+ int cores = Runtime.getRuntime().availableProcessors();
+ if (cores > i) {
+ i = cores;
+ }
+ } catch (Throwable t) {
+ // ignore
+ i = 20;
+ }
+
if (i <= 0) {
i = 20;
}
+
+ LOG.debug("StaxConverter pool size: {}", i);
+
INPUT_FACTORY_POOL = new LinkedBlockingQueue<XMLInputFactory>(i);
OUTPUT_FACTORY_POOL = new LinkedBlockingQueue<XMLOutputFactory>(i);
}
@@ -102,12 +112,6 @@ public class StaxConverter {
public XMLEventWriter createXMLEventWriter(Result result) throws XMLStreamException {
XMLOutputFactory factory = getOutputFactory();
try {
- if (result instanceof DOMResult && !isWoodstox(factory)) {
- //FIXME - if not woodstox, this will likely not work well
- //likely should copy CXF's W3CDOM stuff
- LOG.info("DOMResult is known to have issues with {0}. We suggest using Woodstox",
- factory.getClass());
- }
return factory.createXMLEventWriter(result);
} finally {
returnXMLOutputFactory(factory);
@@ -138,12 +142,6 @@ public class StaxConverter {
public XMLStreamWriter createXMLStreamWriter(Result result) throws XMLStreamException {
XMLOutputFactory factory = getOutputFactory();
try {
- if (result instanceof DOMResult && !isWoodstox(factory)) {
- //FIXME - if not woodstox, this will likely not work well
- //likely should copy CXF's W3CDOM stuff
- LOG.info("DOMResult is known to have issues with {0}. We suggest using Woodstox",
- factory.getClass());
- }
return factory.createXMLStreamWriter(result);
} finally {
returnXMLOutputFactory(factory);
@@ -202,12 +200,6 @@ public class StaxConverter {
public XMLStreamReader createXMLStreamReader(Source in) throws XMLStreamException {
XMLInputFactory factory = getInputFactory();
try {
- if (in instanceof DOMSource && !isWoodstox(factory)) {
- //FIXME - if not woodstox, this will likely not work well
- //likely should copy CXF's W3CDOM stuff
- LOG.info("DOMSource is known to have issues with {0}. We suggest using Woodstox",
- factory.getClass());
- }
return factory.createXMLStreamReader(in);
} finally {
returnXMLInputFactory(factory);
@@ -286,18 +278,13 @@ public class StaxConverter {
public XMLEventReader createXMLEventReader(Source in) throws XMLStreamException {
XMLInputFactory factory = getInputFactory();
try {
- if (in instanceof DOMSource && !isWoodstox(factory)) {
- //FIXME - if not woodstox, this will likely not work well
- LOG.info("DOMSource is known to have issues with {0}. We suggest using Woodstox",
- factory.getClass());
- }
return factory.createXMLEventReader(in);
} finally {
returnXMLInputFactory(factory);
}
}
- private boolean isWoodstox(Object factory) {
+ private static boolean isWoodstox(Object factory) {
return factory.getClass().getPackage().getName().startsWith("com.ctc.wstx");
}
@@ -342,6 +329,14 @@ public class StaxConverter {
throw new XMLStreamException("Reading external entities is disabled");
}
});
+
+ if (isWoodstox(factory)) {
+ // just log a debug as we are good then
+ LOG.debug("Created Woodstox XMLInputFactory: {}", factory);
+ } else {
+ // log a hint that woodstock may be a better factory to use
+ LOG.info("Created XMLInputFactory: {}. DOMSource/DOMResult may have issues with {}. We suggest using Woodstox.", factory, factory);
+ }
return factory;
}
[2/3] git commit: CAMEL-7309: Reduce excessive INFO logging if using
stax converter with woodstox on classpath.
Posted by da...@apache.org.
CAMEL-7309: Reduce excessive INFO logging if using stax converter with woodstox on classpath.
Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/c6b37c45
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/c6b37c45
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/c6b37c45
Branch: refs/heads/camel-2.13.x
Commit: c6b37c45d6774502cb1421a86f71ec992ef27460
Parents: 65a5871
Author: Claus Ibsen <da...@apache.org>
Authored: Tue Mar 18 16:59:59 2014 +0100
Committer: Claus Ibsen <da...@apache.org>
Committed: Tue Mar 18 17:00:12 2014 +0100
----------------------------------------------------------------------
.../camel/converter/jaxp/StaxConverter.java | 53 +++++++++-----------
1 file changed, 24 insertions(+), 29 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/camel/blob/c6b37c45/camel-core/src/main/java/org/apache/camel/converter/jaxp/StaxConverter.java
----------------------------------------------------------------------
diff --git a/camel-core/src/main/java/org/apache/camel/converter/jaxp/StaxConverter.java b/camel-core/src/main/java/org/apache/camel/converter/jaxp/StaxConverter.java
index ca16a11..6a908e6 100644
--- a/camel-core/src/main/java/org/apache/camel/converter/jaxp/StaxConverter.java
+++ b/camel-core/src/main/java/org/apache/camel/converter/jaxp/StaxConverter.java
@@ -32,8 +32,6 @@ import javax.xml.stream.XMLStreamReader;
import javax.xml.stream.XMLStreamWriter;
import javax.xml.transform.Result;
import javax.xml.transform.Source;
-import javax.xml.transform.dom.DOMResult;
-import javax.xml.transform.dom.DOMSource;
import org.apache.camel.Converter;
import org.apache.camel.Exchange;
@@ -48,10 +46,8 @@ import org.slf4j.LoggerFactory;
*/
@Converter
public class StaxConverter {
- private static final Logger LOG = LoggerFactory.getLogger(XmlErrorListener.class);
+ private static final Logger LOG = LoggerFactory.getLogger(StaxConverter.class);
- // TODO: do not use a cxf system property
- // TODO: make higher default pool size as 20 is not much in high end systems
private static final BlockingQueue<XMLInputFactory> INPUT_FACTORY_POOL;
private static final BlockingQueue<XMLOutputFactory> OUTPUT_FACTORY_POOL;
static {
@@ -68,9 +64,23 @@ public class StaxConverter {
//ignore
i = 20;
}
+ try {
+ // if we have more cores than 20, then use that
+ int cores = Runtime.getRuntime().availableProcessors();
+ if (cores > i) {
+ i = cores;
+ }
+ } catch (Throwable t) {
+ // ignore
+ i = 20;
+ }
+
if (i <= 0) {
i = 20;
}
+
+ LOG.debug("StaxConverter pool size: {}", i);
+
INPUT_FACTORY_POOL = new LinkedBlockingQueue<XMLInputFactory>(i);
OUTPUT_FACTORY_POOL = new LinkedBlockingQueue<XMLOutputFactory>(i);
}
@@ -102,12 +112,6 @@ public class StaxConverter {
public XMLEventWriter createXMLEventWriter(Result result) throws XMLStreamException {
XMLOutputFactory factory = getOutputFactory();
try {
- if (result instanceof DOMResult && !isWoodstox(factory)) {
- //FIXME - if not woodstox, this will likely not work well
- //likely should copy CXF's W3CDOM stuff
- LOG.info("DOMResult is known to have issues with {0}. We suggest using Woodstox",
- factory.getClass());
- }
return factory.createXMLEventWriter(result);
} finally {
returnXMLOutputFactory(factory);
@@ -138,12 +142,6 @@ public class StaxConverter {
public XMLStreamWriter createXMLStreamWriter(Result result) throws XMLStreamException {
XMLOutputFactory factory = getOutputFactory();
try {
- if (result instanceof DOMResult && !isWoodstox(factory)) {
- //FIXME - if not woodstox, this will likely not work well
- //likely should copy CXF's W3CDOM stuff
- LOG.info("DOMResult is known to have issues with {0}. We suggest using Woodstox",
- factory.getClass());
- }
return factory.createXMLStreamWriter(result);
} finally {
returnXMLOutputFactory(factory);
@@ -202,12 +200,6 @@ public class StaxConverter {
public XMLStreamReader createXMLStreamReader(Source in) throws XMLStreamException {
XMLInputFactory factory = getInputFactory();
try {
- if (in instanceof DOMSource && !isWoodstox(factory)) {
- //FIXME - if not woodstox, this will likely not work well
- //likely should copy CXF's W3CDOM stuff
- LOG.info("DOMSource is known to have issues with {0}. We suggest using Woodstox",
- factory.getClass());
- }
return factory.createXMLStreamReader(in);
} finally {
returnXMLInputFactory(factory);
@@ -286,18 +278,13 @@ public class StaxConverter {
public XMLEventReader createXMLEventReader(Source in) throws XMLStreamException {
XMLInputFactory factory = getInputFactory();
try {
- if (in instanceof DOMSource && !isWoodstox(factory)) {
- //FIXME - if not woodstox, this will likely not work well
- LOG.info("DOMSource is known to have issues with {0}. We suggest using Woodstox",
- factory.getClass());
- }
return factory.createXMLEventReader(in);
} finally {
returnXMLInputFactory(factory);
}
}
- private boolean isWoodstox(Object factory) {
+ private static boolean isWoodstox(Object factory) {
return factory.getClass().getPackage().getName().startsWith("com.ctc.wstx");
}
@@ -342,6 +329,14 @@ public class StaxConverter {
throw new XMLStreamException("Reading external entities is disabled");
}
});
+
+ if (isWoodstox(factory)) {
+ // just log a debug as we are good then
+ LOG.debug("Created Woodstox XMLInputFactory: {}", factory);
+ } else {
+ // log a hint that woodstock may be a better factory to use
+ LOG.info("Created XMLInputFactory: {}. DOMSource/DOMResult may have issues with {}. We suggest using Woodstox.", factory, factory);
+ }
return factory;
}