Simplify getContentCount.
authormarkt <markt@13f79535-47bb-0310-9956-ffa450edef68>
Wed, 5 Jan 2011 10:10:29 +0000 (10:10 +0000)
committermarkt <markt@13f79535-47bb-0310-9956-ffa450edef68>
Wed, 5 Jan 2011 10:10:29 +0000 (10:10 +0000)
Prep for fixing bug 50496

git-svn-id: https://svn.apache.org/repos/asf/tomcat/trunk@1055391 13f79535-47bb-0310-9956-ffa450edef68

java/org/apache/catalina/connector/OutputBuffer.java
java/org/apache/catalina/connector/Response.java
java/org/apache/catalina/valves/AccessLogValve.java
java/org/apache/catalina/valves/ErrorReportValve.java
java/org/apache/catalina/valves/JDBCAccessLogValve.java

index ef3460f..e9bfc2c 100644 (file)
@@ -340,6 +340,7 @@ public class OutputBuffer extends Writer
      * 
      * @throws IOException An underlying IOException occurred
      */
+    @Override
     public void realWriteBytes(byte buf[], int off, int cnt)
             throws IOException {
 
@@ -513,6 +514,7 @@ public class OutputBuffer extends Writer
                     conv = AccessController.doPrivileged(
                             new PrivilegedExceptionAction<C2BConverter>(){
 
+                                @Override
                                 public C2BConverter run() throws IOException{
                                     return new C2BConverter(bb, enc);
                                 }
@@ -547,29 +549,7 @@ public class OutputBuffer extends Writer
 
     }
 
-    public int getBytesWritten() {
-        if (bytesWritten < Integer.MAX_VALUE) {
-            return (int) bytesWritten;
-        }
-        return -1;
-    }
-
-    public int getCharsWritten() {
-        if (charsWritten < Integer.MAX_VALUE) {
-            return (int) charsWritten;
-        }
-        return -1;
-    }
-
-    public int getContentWritten() {
-        long size = bytesWritten + charsWritten ;
-        if (size < Integer.MAX_VALUE) {
-            return (int) size;
-        }
-        return -1;
-    }
-
-    public long getContentWrittenLong() {
+    public long getContentWritten() {
         return bytesWritten + charsWritten;
     }
     
index b7ada95..98d05a3 100644 (file)
@@ -310,16 +310,9 @@ public class Response
     /**
      * Return the number of bytes actually written to the output stream.
      */
-    public int getContentCount() {
+    public long 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.
index d26f1b6..b71a89b 100644 (file)
@@ -1057,7 +1057,7 @@ public class AccessLogValve extends ValveBase implements AccessLog {
         @Override
         public void addElement(StringBuilder buf, Date date, Request request,
                 Response response, long time) {
-            long length = response.getContentCountLong() ;
+            long length = response.getContentCount() ;
             if (length <= 0 && conversion) {
                 buf.append('-');
             } else {
index ec10004..5ad3e1e 100644 (file)
@@ -165,7 +165,7 @@ public class ErrorReportValve extends ValveBase {
 
         // Do nothing on a 1xx, 2xx and 3xx status
         // Do nothing if anything has been written already
-        if ((statusCode < 400) || (response.getContentCountLong() > 0))
+        if ((statusCode < 400) || (response.getContentCount() > 0))
             return;
 
         String message = RequestUtil.filter(response.getMessage());
index ba592c9..d8e9493 100644 (file)
@@ -464,7 +464,7 @@ public final class JDBCAccessLogValve extends ValveBase implements AccessLog {
         String user = request.getRemoteUser();
         String query=request.getRequestURI();
         
-        long bytes = response.getContentCountLong() ;
+        long bytes = response.getContentCount() ;
         if(bytes < 0)
             bytes = 0;
         int status = response.getStatus();