cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cohei...@apache.org
Subject [cxf] 06/07: Only read the default threshold system property once
Date Wed, 06 Jun 2018 17:10:42 GMT
This is an automated email from the ASF dual-hosted git repository.

coheigea pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/cxf.git

commit 2f7fcc9cd52fa063947c249135592918b314836c
Author: Colm O hEigeartaigh <coheigea@apache.org>
AuthorDate: Wed Jun 6 15:54:39 2018 +0100

    Only read the default threshold system property once
---
 .../main/java/org/apache/cxf/attachment/AttachmentUtil.java    |  4 +---
 core/src/main/java/org/apache/cxf/io/CachedOutputStream.java   | 10 ++++++++++
 2 files changed, 11 insertions(+), 3 deletions(-)

diff --git a/core/src/main/java/org/apache/cxf/attachment/AttachmentUtil.java b/core/src/main/java/org/apache/cxf/attachment/AttachmentUtil.java
index 448eef8..6e6277c 100644
--- a/core/src/main/java/org/apache/cxf/attachment/AttachmentUtil.java
+++ b/core/src/main/java/org/apache/cxf/attachment/AttachmentUtil.java
@@ -53,10 +53,8 @@ import javax.activation.MailcapCommandMap;
 import javax.activation.URLDataSource;
 
 import org.apache.cxf.common.util.StringUtils;
-import org.apache.cxf.common.util.SystemPropertyAction;
 import org.apache.cxf.helpers.HttpHeaderHelper;
 import org.apache.cxf.interceptor.Fault;
-import org.apache.cxf.io.CachedConstants;
 import org.apache.cxf.io.CachedOutputStream;
 import org.apache.cxf.message.Attachment;
 import org.apache.cxf.message.Message;
@@ -179,7 +177,7 @@ public final class AttachmentUtil {
             } else {
                 bos.setThreshold(Long.parseLong((String)threshold));
             }
-        } else if (SystemPropertyAction.getProperty(CachedConstants.THRESHOLD_SYS_PROP) ==
null) {
+        } else if (!CachedOutputStream.isThresholdSysPropSet()) {
             // Use the default AttachmentDeserializer Threshold only if there is no system
property defined
             bos.setThreshold(AttachmentDeserializer.THRESHOLD);
         }
diff --git a/core/src/main/java/org/apache/cxf/io/CachedOutputStream.java b/core/src/main/java/org/apache/cxf/io/CachedOutputStream.java
index bbdb49e..56cf5bd 100644
--- a/core/src/main/java/org/apache/cxf/io/CachedOutputStream.java
+++ b/core/src/main/java/org/apache/cxf/io/CachedOutputStream.java
@@ -53,6 +53,7 @@ public class CachedOutputStream extends OutputStream {
     private static int defaultThreshold;
     private static long defaultMaxSize;
     private static String defaultCipherTransformation;
+    private static boolean thresholdSysPropSet;
 
     static {
         String s = SystemPropertyAction.getPropertyOrNull(CachedConstants.OUTPUT_DIRECTORY_SYS_PROP);
@@ -586,12 +587,21 @@ public class CachedOutputStream extends OutputStream {
             i = Integer.parseInt(s);
             if (i <= 0) {
                 i = 128 * 1024;
+            } else {
+                thresholdSysPropSet = true;
             }
         }
         defaultThreshold = i;
 
     }
 
+    /**
+     * Returns true if the default threshold is explicitly set via CachedConstants.THRESHOLD_SYS_PROP
+     */
+    public static boolean isThresholdSysPropSet() {
+        return thresholdSysPropSet;
+    }
+
     public static void setDefaultCipherTransformation(String n) {
         if (n == null) {
             n = SystemPropertyAction.getPropertyOrNull(CachedConstants.CIPHER_TRANSFORMATION_SYS_PROP);

-- 
To stop receiving notification emails like this one, please contact
coheigea@apache.org.

Mime
View raw message