Author: niallp
Date: Sun Oct 8 14:35:45 2006
New Revision: 454217
URL: http://svn.apache.org/viewvc?view=rev&rev=454217
Log:
Fix for IO-84 - Files over 2GB will result in an incorrect count being returned
by the getCount() and resetCount() methods (as they return an integer). These
methods have been deprecated and new getByteCount() and resetByteCount()
methods have been added which return a long.
Modified:
jakarta/commons/proper/io/trunk/src/java/org/apache/commons/io/input/CountingInputStream.java
jakarta/commons/proper/io/trunk/src/java/org/apache/commons/io/output/CountingOutputStream.java
Modified:
jakarta/commons/proper/io/trunk/src/java/org/apache/commons/io/input/CountingInputStream.java
URL:
http://svn.apache.org/viewvc/jakarta/commons/proper/io/trunk/src/java/org/apache/commons/io/input/CountingInputStream.java?view=diff&rev=454217&r1=454216&r2=454217
==============================================================================
---
jakarta/commons/proper/io/trunk/src/java/org/apache/commons/io/input/CountingInputStream.java
(original)
+++
jakarta/commons/proper/io/trunk/src/java/org/apache/commons/io/input/CountingInputStream.java
Sun Oct 8 14:35:45 2006
@@ -30,7 +30,7 @@
public class CountingInputStream extends ProxyInputStream {
/** The count of bytes that have passed. */
- private int count;
+ private long count;
/**
* Constructs a new CountingInputStream.
@@ -86,20 +86,58 @@
/**
* The number of bytes that have passed through this stream.
+ * <p>
+ * <strong>WARNING</strong> This method will return an
+ * incorrect count for files over 2GB - use
+ * <code>getByteCount()</code> instead.
*
* @return the number of bytes accumulated
+ * @deprecated use <code>getByteCount()</code> - see issue IO-84
*/
public int getCount() {
- return this.count;
+ return (int)getByteCount();
}
/**
* Set the count back to 0.
+ * <p>
+ * <strong>WARNING</strong> This method will return an
+ * incorrect count for files over 2GB - use
+ * <code>resetByteCount()</code> instead.
*
* @return the count previous to resetting.
+ * @deprecated use <code>resetByteCount()</code> - see issue IO-84
*/
public synchronized int resetCount() {
- int tmp = this.count;
+ return (int)resetByteCount();
+ }
+
+ /**
+ * The number of bytes that have passed through this stream.
+ * <p>
+ * <strong>N.B.</strong> This method was introduced as an
+ * alternative for the <code>getCount()</code> method
+ * because that method returns an integer which will result
+ * in incorrect count for files over 2GB being returned.
+ *
+ * @return the number of bytes accumulated
+ */
+ public long getByteCount() {
+ return this.count;
+ }
+
+ /**
+ * Set the count back to 0.
+ * <p>
+ * <strong>N.B.</strong> This method was introduced as an
+ * alternative for the <code>resetCount()</code> method
+ * because that method returns an integer which will result
+ * in incorrect count for files over 2GB being returned.
+ *
+ * @return the count previous to resetting.
+ */
+ public synchronized long resetByteCount() {
+ long tmp = this.count;
this.count = 0;
return tmp;
}
Modified:
jakarta/commons/proper/io/trunk/src/java/org/apache/commons/io/output/CountingOutputStream.java
URL:
http://svn.apache.org/viewvc/jakarta/commons/proper/io/trunk/src/java/org/apache/commons/io/output/CountingOutputStream.java?view=diff&rev=454217&r1=454216&r2=454217
==============================================================================
---
jakarta/commons/proper/io/trunk/src/java/org/apache/commons/io/output/CountingOutputStream.java
(original)
+++
jakarta/commons/proper/io/trunk/src/java/org/apache/commons/io/output/CountingOutputStream.java
Sun Oct 8 14:35:45 2006
@@ -28,7 +28,7 @@
*/
public class CountingOutputStream extends ProxyOutputStream {
- private int count;
+ private long count;
/**
* Constructs a CountingOutputStream.
@@ -58,19 +58,58 @@
/**
* The number of bytes that have passed through this stream.
+ * <p>
+ * <strong>WARNING</strong> This method will return an
+ * incorrect count for files over 2GB - use
+ * <code>getByteCount()</code> instead.
+ *
* @return the number of bytes accumulated
+ * @deprecated use <code>getByteCount()</code> - see issue IO-84
*/
public int getCount() {
- return this.count;
+ return (int)getByteCount();
}
/**
* Set the count back to 0.
+ * <p>
+ * <strong>WARNING</strong> This method will return an
+ * incorrect count for files over 2GB - use
+ * <code>resetByteCount()</code> instead.
*
* @return the count previous to resetting.
+ * @deprecated use <code>resetByteCount()</code> - see issue IO-84
*/
public synchronized int resetCount() {
- int tmp = this.count;
+ return (int)resetByteCount();
+ }
+
+ /**
+ * The number of bytes that have passed through this stream.
+ * <p>
+ * <strong>N.B.</strong> This method was introduced as an
+ * alternative for the <code>getCount()</code> method
+ * because that method returns an integer which will result
+ * in incorrect count for files over 2GB being returned.
+ *
+ * @return the number of bytes accumulated
+ */
+ public long getByteCount() {
+ return this.count;
+ }
+
+ /**
+ * Set the count back to 0.
+ * <p>
+ * <strong>N.B.</strong> This method was introduced as an
+ * alternative for the <code>resetCount()</code> method
+ * because that method returns an integer which will result
+ * in incorrect count for files over 2GB being returned.
+ *
+ * @return the count previous to resetting.
+ */
+ public synchronized long resetByteCount() {
+ long tmp = this.count;
this.count = 0;
return tmp;
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]