Author: dkulp
Date: Wed Jun 6 17:56:50 2012
New Revision: 1347004
URL: http://svn.apache.org/viewvc?rev=1347004&view=rev
Log:
Merged revisions 1345413 via git cherry-pick from
https://svn.apache.org/repos/asf/cxf/trunk
........
r1345413 | dkulp | 2012-06-01 21:54:01 -0400 (Fri, 01 Jun 2012) | 2 lines
Allow configuring the statics to make it easier for testing
........
Modified:
cxf/branches/2.5.x-fixes/api/src/main/java/org/apache/cxf/io/CachedOutputStream.java
Modified:
cxf/branches/2.5.x-fixes/api/src/main/java/org/apache/cxf/io/CachedOutputStream.java
URL:
http://svn.apache.org/viewvc/cxf/branches/2.5.x-fixes/api/src/main/java/org/apache/cxf/io/CachedOutputStream.java?rev=1347004&r1=1347003&r2=1347004&view=diff
==============================================================================
---
cxf/branches/2.5.x-fixes/api/src/main/java/org/apache/cxf/io/CachedOutputStream.java
(original)
+++
cxf/branches/2.5.x-fixes/api/src/main/java/org/apache/cxf/io/CachedOutputStream.java
Wed Jun 6 17:56:50 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;
+
+ }
}