cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dk...@apache.org
Subject svn commit: r1345413 - /cxf/trunk/api/src/main/java/org/apache/cxf/io/CachedOutputStream.java
Date Sat, 02 Jun 2012 01:54:02 GMT
Author: dkulp
Date: Sat Jun  2 01:54:01 2012
New Revision: 1345413

URL: http://svn.apache.org/viewvc?rev=1345413&view=rev
Log:
Allow configuring the statics to make it easier for testing

Modified:
    cxf/trunk/api/src/main/java/org/apache/cxf/io/CachedOutputStream.java

Modified: cxf/trunk/api/src/main/java/org/apache/cxf/io/CachedOutputStream.java
URL: http://svn.apache.org/viewvc/cxf/trunk/api/src/main/java/org/apache/cxf/io/CachedOutputStream.java?rev=1345413&r1=1345412&r2=1345413&view=diff
==============================================================================
--- cxf/trunk/api/src/main/java/org/apache/cxf/io/CachedOutputStream.java (original)
+++ cxf/trunk/api/src/main/java/org/apache/cxf/io/CachedOutputStream.java Sat Jun  2 01:54:01
2012
@@ -42,18 +42,11 @@ import org.apache.cxf.helpers.LoadingByt
 
 public class CachedOutputStream extends OutputStream {
     private static final File DEFAULT_TEMP_DIR;
-    private static final int DEFAULT_THRESHOLD;
-    private static final long DEFAULT_MAX_SIZE;
+    private static int defaultThreshold;
+    private static long defaultMaxSize;
     static {
-        String s = SystemPropertyAction.getProperty("org.apache.cxf.io.CachedOutputStream.Threshold",
-                                                   "-1");
-        int i = Integer.parseInt(s);
-        if (i <= 0) {
-            i = 64 * 1024;
-        }
-        DEFAULT_THRESHOLD = i;
         
-        s = SystemPropertyAction.getPropertyOrNull("org.apache.cxf.io.CachedOutputStream.OutputDirectory");
+        String s = SystemPropertyAction.getPropertyOrNull("org.apache.cxf.io.CachedOutputStream.OutputDirectory");
         if (s != null) {
             File f = new File(s);
             if (f.exists() && f.isDirectory()) {
@@ -65,16 +58,15 @@ public class CachedOutputStream extends 
             DEFAULT_TEMP_DIR = null;
         }
 
-        s = System.getProperty("org.apache.cxf.io.CachedOutputStream.MaxSize",
-                               "-1");
-        DEFAULT_MAX_SIZE = Long.parseLong(s);
+        setDefaultThreshold(-1);
+        setDefaultMaxSize(-1);
     }
 
     protected boolean outputLocked;
     protected OutputStream currentStream;
 
-    private long threshold = DEFAULT_THRESHOLD;
-    private long maxSize = DEFAULT_MAX_SIZE;
+    private long threshold = defaultThreshold;
+    private long maxSize = defaultMaxSize;
 
     private long totalLength;
 
@@ -519,4 +511,25 @@ public class CachedOutputStream extends 
     public void setMaxSize(long maxSize) {
         this.maxSize = maxSize;
     }
+    
+    public static void setDefaultMaxSize(long l) {
+        if (l == -1) {
+            String s = System.getProperty("org.apache.cxf.io.CachedOutputStream.MaxSize",
+                    "-1");
+            l = Long.parseLong(s);
+        }
+        defaultMaxSize = l;
+    }
+    public static void setDefaultThreshold(int i) {
+        if (i == -1) {
+            String s = SystemPropertyAction.getProperty("org.apache.cxf.io.CachedOutputStream.Threshold",
+                "-1");
+            i = Integer.parseInt(s);
+            if (i <= 0) {
+                i = 64 * 1024;
+            }
+        }
+        defaultThreshold = i;
+        
+    }
 }



Mime
View raw message