Author: markt
Date: Mon Jan 15 22:43:13 2018
New Revision: 1821203

URL: http://svn.apache.org/viewvc?rev=1821203&view=rev
Log:
Align ByteChunk and CharChunk

Modified:
    tomcat/trunk/java/org/apache/tomcat/util/buf/CharChunk.java

Modified: tomcat/trunk/java/org/apache/tomcat/util/buf/CharChunk.java
URL: 
http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/tomcat/util/buf/CharChunk.java?rev=1821203&r1=1821202&r2=1821203&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/tomcat/util/buf/CharChunk.java (original)
+++ tomcat/trunk/java/org/apache/tomcat/util/buf/CharChunk.java Mon Jan 15 
22:43:13 2018
@@ -324,30 +324,17 @@ public final class CharChunk extends Abs
     // -------------------- Removing data from the buffer --------------------
 
     public int substract() throws IOException {
-        if ((end - start) == 0) {
-            if (in == null) {
-                return -1;
-            }
-            int n = in.realReadChars();
-            if (n < 0) {
-                return -1;
-            }
+        if (checkEof()) {
+            return -1;
         }
-        return (buff[start++]);
+        return buff[start++];
     }
 
 
     public int substract(char dest[], int off, int len) throws IOException {
-        if ((end - start) == 0) {
-            if (in == null) {
-                return -1;
-            }
-            int n = in.realReadChars();
-            if (n < 0) {
-                return -1;
-            }
+        if (checkEof()) {
+            return -1;
         }
-
         int n = len;
         if (len > getLength()) {
             n = getLength();
@@ -358,6 +345,20 @@ public final class CharChunk extends Abs
     }
 
 
+    private boolean checkEof() throws IOException {
+        if ((end - start) == 0) {
+            if (in == null) {
+                return true;
+            }
+            int n = in.realReadChars();
+            if (n < 0) {
+                return true;
+            }
+        }
+        return false;
+    }
+
+
     public void flushBuffer() throws IOException {
         // assert out!=null
         if (out == null) {



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to