Modified: 
tomcat/tc7.0.x/trunk/test/org/apache/tomcat/util/buf/TestByteChunk.java
URL: 
http://svn.apache.org/viewvc/tomcat/tc7.0.x/trunk/test/org/apache/tomcat/util/buf/TestByteChunk.java?rev=1821322&r1=1821321&r2=1821322&view=diff
==============================================================================
--- tomcat/tc7.0.x/trunk/test/org/apache/tomcat/util/buf/TestByteChunk.java 
(original)
+++ tomcat/tc7.0.x/trunk/test/org/apache/tomcat/util/buf/TestByteChunk.java Tue 
Jan 16 21:56:18 2018
@@ -16,12 +16,16 @@
  */
 package org.apache.tomcat.util.buf;
 
+import java.io.IOException;
 import java.io.UnsupportedEncodingException;
 import java.util.Arrays;
 
 import org.junit.Assert;
+import org.junit.Ignore;
 import org.junit.Test;
 
+import org.apache.tomcat.util.buf.ByteChunk.ByteOutputChannel;
+
 /**
  * Test cases for {@link ByteChunk}.
  */
@@ -35,7 +39,7 @@ public class TestByteChunk {
         Assert.assertTrue(Arrays.equals(bytes, expected));
     }
 
-    /**
+    /*
      * Test for {@code findByte} vs. {@code indexOf} methods difference.
      *
      * <p>
@@ -70,6 +74,7 @@ public class TestByteChunk {
         Assert.assertEquals(-1, ByteChunk.indexOf(bytes, 5, 5, 'w'));
     }
 
+
     @Test
     public void testIndexOf_Char() throws UnsupportedEncodingException {
         byte[] bytes = "Hello\u00a0world".getBytes("ISO-8859-1");
@@ -92,6 +97,7 @@ public class TestByteChunk {
         Assert.assertEquals(-1, bc.indexOf('d', 0));
     }
 
+
     @Test
     public void testIndexOf_String() throws UnsupportedEncodingException {
         byte[] bytes = "Hello\u00a0world".getBytes("ISO-8859-1");
@@ -117,6 +123,7 @@ public class TestByteChunk {
         Assert.assertEquals(-1, bc.indexOf("d", 0, 1, 0));
     }
 
+
     @Test
     public void testFindBytes() throws UnsupportedEncodingException {
         byte[] bytes = "Hello\u00a0world".getBytes("ISO-8859-1");
@@ -134,6 +141,7 @@ public class TestByteChunk {
         Assert.assertEquals(-1, ByteChunk.findBytes(bytes, 2, 5, new byte[] { 
'w' }));
     }
 
+
     @Test
     @Deprecated
     public void testFindNotBytes() throws UnsupportedEncodingException {
@@ -146,4 +154,30 @@ public class TestByteChunk {
         Assert.assertEquals(-1, ByteChunk.findNotBytes(bytes, 2, 3, new byte[] 
{ 'l',
                 'e', 'H' }));
     }
+
+
+    @Ignore // Requires a 6GB heap (on markt's desktop - YMMV)
+    @Test
+    public void testAppend() throws Exception {
+        ByteChunk bc = new ByteChunk();
+        bc.setByteOutputChannel(new Sink());
+        // Defaults to no limit
+
+        byte data[] = new byte[32 * 1024 * 1024];
+
+        for (int i = 0; i < 100; i++) {
+            bc.append(data, 0, data.length);
+        }
+
+        Assert.assertEquals(AbstractChunk.ARRAY_MAX_SIZE, 
bc.getBuffer().length);
+    }
+
+
+    public class Sink implements ByteOutputChannel {
+
+        @Override
+        public void realWriteBytes(byte[] cbuf, int off, int len) throws 
IOException {
+            // NO-OP
+        }
+    }
 }

Modified: 
tomcat/tc7.0.x/trunk/test/org/apache/tomcat/util/buf/TestCharChunk.java
URL: 
http://svn.apache.org/viewvc/tomcat/tc7.0.x/trunk/test/org/apache/tomcat/util/buf/TestCharChunk.java?rev=1821322&r1=1821321&r2=1821322&view=diff
==============================================================================
--- tomcat/tc7.0.x/trunk/test/org/apache/tomcat/util/buf/TestCharChunk.java 
(original)
+++ tomcat/tc7.0.x/trunk/test/org/apache/tomcat/util/buf/TestCharChunk.java Tue 
Jan 16 21:56:18 2018
@@ -16,9 +16,14 @@
  */
 package org.apache.tomcat.util.buf;
 
+import java.io.IOException;
+
 import org.junit.Assert;
+import org.junit.Ignore;
 import org.junit.Test;
 
+import org.apache.tomcat.util.buf.CharChunk.CharOutputChannel;
+
 /**
  * Test cases for {@link CharChunk}.
  */
@@ -37,6 +42,7 @@ public class TestCharChunk {
         Assert.assertFalse(cc.endsWith("xxtest"));
     }
 
+
     @Test
     public void testIndexOf_String() {
         char[] chars = "Hello\u00a0world".toCharArray();
@@ -62,4 +68,29 @@ public class TestCharChunk {
         Assert.assertEquals(-1, cc.indexOf("d", 0, 1, 0));
     }
 
+
+    @Ignore // Requires an 11GB heap (on markt's desktop - YMMV)
+    @Test
+    public void testAppend() throws Exception {
+        CharChunk cc = new CharChunk();
+        cc.setCharOutputChannel(new Sink());
+        // Defaults to no limit
+
+        char data[] = new char[32 * 1024 * 1024];
+
+        for (int i = 0; i < 100; i++) {
+            cc.append(data, 0, data.length);
+        }
+
+        Assert.assertEquals(AbstractChunk.ARRAY_MAX_SIZE, 
cc.getBuffer().length);
+    }
+
+
+    public class Sink implements CharOutputChannel {
+
+        @Override
+        public void realWriteChars(char[] cbuf, int off, int len) throws 
IOException {
+            // NO-OP
+        }
+    }
 }

Modified: tomcat/tc7.0.x/trunk/webapps/docs/changelog.xml
URL: 
http://svn.apache.org/viewvc/tomcat/tc7.0.x/trunk/webapps/docs/changelog.xml?rev=1821322&r1=1821321&r2=1821322&view=diff
==============================================================================
--- tomcat/tc7.0.x/trunk/webapps/docs/changelog.xml (original)
+++ tomcat/tc7.0.x/trunk/webapps/docs/changelog.xml Tue Jan 16 21:56:18 2018
@@ -101,6 +101,11 @@
         made available to the application via the asynchronous error handling
         mechanism. (markt)
       </fix>
+      <fix>
+        <bug>61993</bug>: Improve handling for <code>ByteChunk</code> and
+        <code>CharChunk</code> instances that grow close to the maximum size
+        allowed by the JRE. (markt)
+      </fix>
     </changelog>
   </subsection>
   <subsection name="Web applications">



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

Reply via email to