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 2021/11/05 05:57:26 UTC
[camel] branch main updated: StaxConverter: Make input and output factory pool size implementation… (#6380)
This is an automated email from the ASF dual-hosted git repository.
davsclaus pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel.git
The following commit(s) were added to refs/heads/main by this push:
new 804fdbb StaxConverter: Make input and output factory pool size implementation… (#6380)
804fdbb is described below
commit 804fdbb205b7ce70adafb8d9b45ef52dff0f4216
Author: Pascal Schumacher <pa...@gmx.net>
AuthorDate: Fri Nov 5 06:56:48 2021 +0100
StaxConverter: Make input and output factory pool size implementation… (#6380)
* StaxConverter: Make input and output factory pool size implementation match comments.
Comments suggests that Runtime#availableProcessors should be used as pool size when it is greater than 20, but the current implementation uses Runtime#availableProcessors regardless of the amount of processors available if the system property "org.apache.cxf.staxutils.pool-size" is not set.
* StaxConverter: Stop using the system property "org.apache.cxf.staxutils.pool-size" when determining the input and output factory pool size.
---
.../apache/camel/converter/jaxp/StaxConverter.java | 33 +++++-----------------
1 file changed, 7 insertions(+), 26 deletions(-)
diff --git a/core/camel-xml-jaxp/src/main/java/org/apache/camel/converter/jaxp/StaxConverter.java b/core/camel-xml-jaxp/src/main/java/org/apache/camel/converter/jaxp/StaxConverter.java
index 1f306f7..294a8f1 100644
--- a/core/camel-xml-jaxp/src/main/java/org/apache/camel/converter/jaxp/StaxConverter.java
+++ b/core/camel-xml-jaxp/src/main/java/org/apache/camel/converter/jaxp/StaxConverter.java
@@ -24,8 +24,6 @@ import java.io.OutputStream;
import java.io.Reader;
import java.io.StringReader;
import java.io.Writer;
-import java.security.AccessController;
-import java.security.PrivilegedAction;
import java.util.concurrent.BlockingQueue;
import java.util.concurrent.LinkedBlockingQueue;
@@ -57,38 +55,21 @@ public class StaxConverter {
private static final BlockingQueue<XMLInputFactory> INPUT_FACTORY_POOL;
private static final BlockingQueue<XMLOutputFactory> OUTPUT_FACTORY_POOL;
static {
- int i = 20;
- try {
- String s = AccessController.doPrivileged(new PrivilegedAction<String>() {
- @Override
- public String run() {
- return System.getProperty("org.apache.cxf.staxutils.pool-size", "-1");
- }
- });
- i = Integer.parseInt(s);
- } catch (Exception t) {
- //ignore
- i = 20;
- }
+ int poolSize = 20;
try {
// if we have more cores than 20, then use that
int cores = Runtime.getRuntime().availableProcessors();
- if (cores > i) {
- i = cores;
+ if (cores > poolSize) {
+ poolSize = cores;
}
- } catch (Exception t) {
+ } catch (Exception ignored) {
// ignore
- i = 20;
- }
-
- if (i <= 0) {
- i = 20;
}
- LOG.debug("StaxConverter pool size: {}", i);
+ LOG.debug("StaxConverter pool size: {}", poolSize);
- INPUT_FACTORY_POOL = new LinkedBlockingQueue<>(i);
- OUTPUT_FACTORY_POOL = new LinkedBlockingQueue<>(i);
+ INPUT_FACTORY_POOL = new LinkedBlockingQueue<>(poolSize);
+ OUTPUT_FACTORY_POOL = new LinkedBlockingQueue<>(poolSize);
}
private XMLInputFactory inputFactory;