This is an automated email from the ASF dual-hosted git repository.

markt pushed a commit to branch 8.5.x
in repository https://gitbox.apache.org/repos/asf/tomcat.git


The following commit(s) were added to refs/heads/8.5.x by this push:
     new 506495b  Fix BZ 65177 reduce memory footprint to avoid OOME on 32-bit 
JVMs
506495b is described below

commit 506495bd5cd8464f6fa2966cf31d3265643173d3
Author: Mark Thomas <ma...@apache.org>
AuthorDate: Tue Mar 9 14:12:42 2021 +0000

    Fix BZ 65177 reduce memory footprint to avoid OOME on 32-bit JVMs
    
    https://bz.apache.org/bugzilla/show_bug.cgi?id=65177
---
 test/org/apache/tomcat/util/net/TestSsl.java | 21 ++++++++++++---------
 1 file changed, 12 insertions(+), 9 deletions(-)

diff --git a/test/org/apache/tomcat/util/net/TestSsl.java 
b/test/org/apache/tomcat/util/net/TestSsl.java
index d489537..dbc9c36 100644
--- a/test/org/apache/tomcat/util/net/TestSsl.java
+++ b/test/org/apache/tomcat/util/net/TestSsl.java
@@ -79,6 +79,12 @@ public class TestSsl extends TomcatBaseTest {
     }
 
     private static final int POST_DATA_SIZE = 16 * 1024 * 1024;
+    private static final byte[] POST_DATA;
+    static {
+        POST_DATA = new byte[POST_DATA_SIZE]; // 16MB
+        Arrays.fill(POST_DATA, (byte) 1);
+
+    }
 
     @Test
     public void testPost() throws Exception {
@@ -106,15 +112,12 @@ public class TestSsl extends TomcatBaseTest {
 
                         OutputStream os = socket.getOutputStream();
 
-                        byte[] bytes = new byte[POST_DATA_SIZE]; // 16MB
-                        Arrays.fill(bytes, (byte) 1);
-
                         os.write("POST /post HTTP/1.1\r\n".getBytes());
                         os.write("Host: localhost\r\n".getBytes());
-                        os.write(("Content-Length: " + 
Integer.valueOf(bytes.length) + "\r\n\r\n").getBytes());
+                        os.write(("Content-Length: " + 
Integer.valueOf(POST_DATA.length) + "\r\n\r\n").getBytes());
                         // Write in 128KB blocks
-                        for (int i = 0; i < bytes.length / (128 * 1024); i++) {
-                            os.write(bytes, 0, 1024 * 128);
+                        for (int i = 0; i < POST_DATA.length / (128 * 1024); 
i++) {
+                            os.write(POST_DATA, 0, 1024 * 128);
                             Thread.sleep(10);
                         }
                         os.flush();
@@ -138,11 +141,11 @@ public class TestSsl extends TomcatBaseTest {
                             }
                         }
 
-                        for (int i = 0; i < bytes.length; i++) {
+                        for (int i = 0; i < POST_DATA.length; i++) {
                             int read = is.read();
-                            if (bytes[i] != read) {
+                            if (POST_DATA[i] != read) {
                                 System.err.println("Byte in position [" + i + 
"] had value [" + read +
-                                        "] rather than [" + 
Byte.toString(bytes[i]) + "]");
+                                        "] rather than [" + 
Byte.toString(POST_DATA[i]) + "]");
                                 errorCount.incrementAndGet();
                                 break;
                             }


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

Reply via email to