tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ma...@apache.org
Subject svn commit: r1044255 - /tomcat/trunk/java/org/apache/catalina/servlets/DefaultServlet.java
Date Fri, 10 Dec 2010 09:47:05 GMT
Author: markt
Date: Fri Dec 10 09:47:05 2010
New Revision: 1044255

URL: http://svn.apache.org/viewvc?rev=1044255&view=rev
Log:
Fix FindBugs / unused code warnings

Modified:
    tomcat/trunk/java/org/apache/catalina/servlets/DefaultServlet.java

Modified: tomcat/trunk/java/org/apache/catalina/servlets/DefaultServlet.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/servlets/DefaultServlet.java?rev=1044255&r1=1044254&r2=1044255&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/servlets/DefaultServlet.java (original)
+++ tomcat/trunk/java/org/apache/catalina/servlets/DefaultServlet.java Fri Dec 10 09:47:05
2010
@@ -184,7 +184,7 @@ public class DefaultServlet
     /**
      * Proxy directory context.
      */
-    protected ProxyDirContext resources = null;
+    protected transient ProxyDirContext resources = null;
 
 
     /**
@@ -2158,12 +2158,17 @@ public class DefaultServlet
         if (debug > 10)
             log("Serving bytes:" + start + "-" + end);
 
+        long skipped = 0;
         try {
-            istream.skip(start);
+            skipped = istream.skip(start);
         } catch (IOException e) {
             return e;
         }
-
+        if (skipped < start) {
+            return new IOException(sm.getString("defaultservlet.skipfail",
+                    Long.valueOf(skipped), Long.valueOf(start)));
+        }
+        
         IOException exception = null;
         long bytesToRead = end - start + 1;
 
@@ -2206,11 +2211,16 @@ public class DefaultServlet
     protected IOException copyRange(Reader reader, PrintWriter writer,
                                   long start, long end) {
 
+        long skipped = 0;
         try {
-            reader.skip(start);
+            skipped = reader.skip(start);
         } catch (IOException e) {
             return e;
         }
+        if (skipped < start) {
+            return new IOException(sm.getString("defaultservlet.skipfail",
+                    Long.valueOf(skipped), Long.valueOf(start)));
+        }
 
         IOException exception = null;
         long bytesToRead = end - start + 1;
@@ -2244,7 +2254,7 @@ public class DefaultServlet
     // ------------------------------------------------------ Range Inner Class
 
 
-    protected class Range {
+    protected static class Range {
 
         public long start;
         public long end;
@@ -2256,17 +2266,7 @@ public class DefaultServlet
         public boolean validate() {
             if (end >= length)
                 end = length - 1;
-            return ( (start >= 0) && (end >= 0) && (start <= end)
-                     && (length > 0) );
+            return (start >= 0) && (end >= 0) && (start <= end)
&& (length > 0);
         }
-
-        public void recycle() {
-            start = 0;
-            end = 0;
-            length = 0;
-        }
-
     }
-
-
 }



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


Mime
View raw message