commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bode...@apache.org
Subject svn commit: r1188601 - in /commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/utils: CountingInputStream.java CountingOutputStream.java
Date Tue, 25 Oct 2011 10:59:20 GMT
Author: bodewig
Date: Tue Oct 25 10:59:19 2011
New Revision: 1188601

URL: http://svn.apache.org/viewvc?rev=1188601&view=rev
Log:
Having a thread-safe count in an otherwise not-thread-safe stream doesn't make much sense

Modified:
    commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/utils/CountingInputStream.java
    commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/utils/CountingOutputStream.java

Modified: commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/utils/CountingInputStream.java
URL: http://svn.apache.org/viewvc/commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/utils/CountingInputStream.java?rev=1188601&r1=1188600&r2=1188601&view=diff
==============================================================================
--- commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/utils/CountingInputStream.java
(original)
+++ commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/utils/CountingInputStream.java
Tue Oct 25 10:59:19 2011
@@ -26,10 +26,10 @@ import java.util.concurrent.atomic.Atomi
 /**
  * Stream that tracks the number of bytes read.
  * @since Apache Commons Compress 1.3
- * @ThreadSafe
+ * @NotThreadSafe
  */
 public class CountingInputStream extends FilterInputStream {
-    private final AtomicLong bytesRead = new AtomicLong();
+    private long bytesRead;
 
     public CountingInputStream(final InputStream in) {
         super(in);
@@ -63,7 +63,7 @@ public class CountingInputStream extends
      */
     protected final void count(long read) {
         if (read != -1) {
-            bytesRead.addAndGet(read);
+            bytesRead += read;
         }
     }
     
@@ -72,6 +72,6 @@ public class CountingInputStream extends
      * @return the number of read bytes
      */
     public long getBytesRead() {
-        return bytesRead.longValue();
+        return bytesRead;
     }
 }

Modified: commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/utils/CountingOutputStream.java
URL: http://svn.apache.org/viewvc/commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/utils/CountingOutputStream.java?rev=1188601&r1=1188600&r2=1188601&view=diff
==============================================================================
--- commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/utils/CountingOutputStream.java
(original)
+++ commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/utils/CountingOutputStream.java
Tue Oct 25 10:59:19 2011
@@ -26,10 +26,10 @@ import java.util.concurrent.atomic.Atomi
 /**
  * Stream that tracks the number of bytes read.
  * @since Apache Commons Compress 1.3
- * @ThreadSafe
+ * @NotThreadSafe
  */
 public class CountingOutputStream extends FilterOutputStream {
-    private final AtomicLong bytesWritten = new AtomicLong();
+    private long bytesWritten = 0;
 
     public CountingOutputStream(final OutputStream out) {
         super(out);
@@ -58,7 +58,7 @@ public class CountingOutputStream extend
      */
     protected void count(long written) {
         if (written != -1) {
-            bytesWritten.addAndGet(written);
+            bytesWritten += written;
         }
     }
     
@@ -67,6 +67,6 @@ public class CountingOutputStream extend
      * @return the number of written bytes
      */
     public long getBytesWritten() {
-        return bytesWritten.longValue();
+        return bytesWritten;
     }
 }



Mime
View raw message