Improve large-file support (more then 4 Gb) at all AccessLogValves, backport from...
authorpero <pero@13f79535-47bb-0310-9956-ffa450edef68>
Thu, 13 Sep 2007 21:56:30 +0000 (21:56 +0000)
committerpero <pero@13f79535-47bb-0310-9956-ffa450edef68>
Thu, 13 Sep 2007 21:56:30 +0000 (21:56 +0000)
git-svn-id: https://svn.apache.org/repos/asf/tomcat/tc6.0.x/trunk@575478 13f79535-47bb-0310-9956-ffa450edef68

java/org/apache/catalina/connector/OutputBuffer.java
java/org/apache/catalina/connector/Response.java

index 4f282a2..769f8b4 100644 (file)
@@ -70,13 +70,13 @@ public class OutputBuffer extends Writer
     /**
      * Number of bytes written.
      */
-    private int bytesWritten = 0;
+    private long bytesWritten = 0;
 
 
     /**
      * Number of chars written.
      */
-    private int charsWritten = 0;
+    private long charsWritten = 0;
 
 
     /**
@@ -539,22 +539,32 @@ public class OutputBuffer extends Writer
 
     }
 
-
     public int getBytesWritten() {
-        return bytesWritten;
+        if (bytesWritten < Integer.MAX_VALUE) {
+            return (int) bytesWritten;
+        }
+        return -1;
     }
 
-
     public int getCharsWritten() {
-        return charsWritten;
+        if (charsWritten < Integer.MAX_VALUE) {
+            return (int) charsWritten;
+        }
+        return -1;
     }
 
-
     public int getContentWritten() {
-        return bytesWritten + charsWritten;
+        long size = bytesWritten + charsWritten ;
+        if (size < Integer.MAX_VALUE) {
+            return (int) size;
+        }
+        return -1;
     }
 
-
+    public long getContentWrittenLong() {
+        return bytesWritten + charsWritten;
+    }
+    
     /** 
      * True if this buffer hasn't been used ( since recycle() ) -
      * i.e. no chars or bytes have been added to the buffer.  
index 058c8c8..e53b4df 100644 (file)
@@ -305,7 +305,13 @@ public class Response
     public int getContentCount() {
         return outputBuffer.getContentWritten();
     }
-
+    
+    /**
+     * Return the number of bytes actually written to the output stream.
+     */
+    public long getContentCountLong() {
+        return outputBuffer.getContentWrittenLong();
+    }
 
     /**
      * Set the application commit flag.