You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by ma...@apache.org on 2020/04/03 08:26:29 UTC
[tomcat] branch 8.5.x updated (3031d06 -> b18e764)
This is an automated email from the ASF dual-hosted git repository.
markt pushed a change to branch 8.5.x
in repository https://gitbox.apache.org/repos/asf/tomcat.git.
from 3031d06 Improve code coverage
new 650cb85 Log exceptions when closing the server socket and don't re-throw
new e0fdcfe Expand SSL POST test to exercise the poller more
new bbf0a02 Fix IDE warning
new e1a7fbc Failed test on Windows. Expand logging to aid debugging of failures.
new b18e764 Changes required for Java 7
The 5 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
Summary of changes:
java/org/apache/tomcat/util/net/NioEndpoint.java | 6 +-
test/org/apache/tomcat/util/net/TestSsl.java | 94 +++++++++++++++---------
2 files changed, 66 insertions(+), 34 deletions(-)
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org
[tomcat] 01/05: Log exceptions when closing the server socket and
don't re-throw
Posted by ma...@apache.org.
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
commit 650cb85ad2871a108c142be7ebf2de67687fe887
Author: Mark Thomas <ma...@apache.org>
AuthorDate: Thu Apr 2 21:23:51 2020 +0100
Log exceptions when closing the server socket and don't re-throw
Running the unit tests on MacOS I saw a test failure caused by an
exception as this point. I've never seen an exception here before. It
certainly isn't repeatable. On balance, logging the exception and
completing the rest of the Connector shutdown cleanly looks to be the
better option.
---
java/org/apache/tomcat/util/net/NioEndpoint.java | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/java/org/apache/tomcat/util/net/NioEndpoint.java b/java/org/apache/tomcat/util/net/NioEndpoint.java
index 4e67f7e..a50b721 100644
--- a/java/org/apache/tomcat/util/net/NioEndpoint.java
+++ b/java/org/apache/tomcat/util/net/NioEndpoint.java
@@ -330,7 +330,11 @@ public class NioEndpoint extends AbstractJsseEndpoint<NioChannel> {
if (running) {
stop();
}
- doCloseServerSocket();
+ try {
+ doCloseServerSocket();
+ } catch (IOException ioe) {
+ getLog().warn(sm.getString("endpoint.serverSocket.closeFailed", getName()), ioe);
+ }
destroySsl();
super.unbind();
if (getHandler() != null ) {
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org
[tomcat] 02/05: Expand SSL POST test to exercise the poller more
Posted by ma...@apache.org.
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
commit e0fdcfef203eff408c940b6b22e4aec5b0679028
Author: remm <re...@apache.org>
AuthorDate: Fri Mar 6 16:55:39 2020 +0100
Expand SSL POST test to exercise the poller more
No issue found so far.
---
test/org/apache/tomcat/util/net/TestSsl.java | 88 ++++++++++++++++++----------
1 file changed, 56 insertions(+), 32 deletions(-)
diff --git a/test/org/apache/tomcat/util/net/TestSsl.java b/test/org/apache/tomcat/util/net/TestSsl.java
index f167c6c..91598fb 100644
--- a/test/org/apache/tomcat/util/net/TestSsl.java
+++ b/test/org/apache/tomcat/util/net/TestSsl.java
@@ -24,6 +24,8 @@ import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.Reader;
import java.util.Arrays;
+import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.atomic.AtomicInteger;
import javax.net.SocketFactory;
import javax.net.ssl.HandshakeCompletedEvent;
@@ -87,39 +89,61 @@ public class TestSsl extends TomcatBaseTest {
Tomcat.addServlet(ctxt, "post", new SimplePostServlet());
ctxt.addServletMappingDecoded("/post", "post");
tomcat.start();
-
- SSLSocket socket = (SSLSocket) socketFactory.createSocket("localhost",
- getPort());
-
- OutputStream os = socket.getOutputStream();
-
- byte[] bytes = new byte[1024 * 1024]; // 1MB
- 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: 1048576\r\n\r\n".getBytes());
- os.write(bytes);
- os.flush();
-
- InputStream is = socket.getInputStream();
-
- // Skip to the end of the headers
- byte[] endOfHeaders = "\r\n\r\n".getBytes();
- int found = 0;
- while (found != endOfHeaders.length) {
- if (is.read() == endOfHeaders[found]) {
- found++;
- } else {
- found = 0;
- }
- }
-
- for (byte c : bytes) {
- int read = is.read();
- Assert.assertEquals(c, read);
+ int iterations = 8;
+ CountDownLatch latch = new CountDownLatch(iterations);
+ AtomicInteger errorCount = new AtomicInteger(0);
+ for (int i = 0; i < iterations; i++) {
+ new Thread() {
+ public void run() {
+ try {
+ SSLSocket socket = (SSLSocket) socketFactory.createSocket("localhost",
+ getPort());
+
+ OutputStream os = socket.getOutputStream();
+
+ byte[] bytes = new byte[16 * 1024 * 1024]; // 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());
+ // Write in 128KB blocks
+ for (int i = 0; i < bytes.length / (128 * 1024); i++) {
+ os.write(bytes, 0, 1024 * 128);
+ Thread.sleep(10);
+ }
+ os.flush();
+
+ InputStream is = socket.getInputStream();
+
+ // Skip to the end of the headers
+ byte[] endOfHeaders = "\r\n\r\n".getBytes();
+ int found = 0;
+ while (found != endOfHeaders.length) {
+ if (is.read() == endOfHeaders[found]) {
+ found++;
+ } else {
+ found = 0;
+ }
+ }
+
+ for (byte c : bytes) {
+ int read = is.read();
+ if (c != read) {
+ errorCount.incrementAndGet();
+ break;
+ }
+ }
+ } catch (Exception e) {
+ errorCount.incrementAndGet();
+ } finally {
+ latch.countDown();
+ }
+ }
+ }.start();
}
-
+ latch.await();
+ Assert.assertEquals(0, errorCount.get());
}
@Test
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org
[tomcat] 05/05: Changes required for Java 7
Posted by ma...@apache.org.
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
commit b18e764ec83a6a98af3d9ef2576b91049f2345f8
Author: Mark Thomas <ma...@apache.org>
AuthorDate: Fri Apr 3 09:26:07 2020 +0100
Changes required for Java 7
---
test/org/apache/tomcat/util/net/TestSsl.java | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/test/org/apache/tomcat/util/net/TestSsl.java b/test/org/apache/tomcat/util/net/TestSsl.java
index ae23179..b072106 100644
--- a/test/org/apache/tomcat/util/net/TestSsl.java
+++ b/test/org/apache/tomcat/util/net/TestSsl.java
@@ -80,7 +80,7 @@ public class TestSsl extends TomcatBaseTest {
@Test
public void testPost() throws Exception {
- SocketFactory socketFactory = TesterSupport.configureClientSsl();
+ final SocketFactory socketFactory = TesterSupport.configureClientSsl();
Tomcat tomcat = getTomcatInstance();
TesterSupport.initSsl(tomcat);
@@ -90,8 +90,8 @@ public class TestSsl extends TomcatBaseTest {
ctxt.addServletMappingDecoded("/post", "post");
tomcat.start();
int iterations = 8;
- CountDownLatch latch = new CountDownLatch(iterations);
- AtomicInteger errorCount = new AtomicInteger(0);
+ final CountDownLatch latch = new CountDownLatch(iterations);
+ final AtomicInteger errorCount = new AtomicInteger(0);
for (int i = 0; i < iterations; i++) {
new Thread() {
@Override
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org
[tomcat] 03/05: Fix IDE warning
Posted by ma...@apache.org.
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
commit bbf0a02f04b4ca1d8d9228c74717a95ea56117d9
Author: Mark Thomas <ma...@apache.org>
AuthorDate: Sat Mar 7 10:14:45 2020 +0000
Fix IDE warning
---
test/org/apache/tomcat/util/net/TestSsl.java | 1 +
1 file changed, 1 insertion(+)
diff --git a/test/org/apache/tomcat/util/net/TestSsl.java b/test/org/apache/tomcat/util/net/TestSsl.java
index 91598fb..1736b49 100644
--- a/test/org/apache/tomcat/util/net/TestSsl.java
+++ b/test/org/apache/tomcat/util/net/TestSsl.java
@@ -94,6 +94,7 @@ public class TestSsl extends TomcatBaseTest {
AtomicInteger errorCount = new AtomicInteger(0);
for (int i = 0; i < iterations; i++) {
new Thread() {
+ @Override
public void run() {
try {
SSLSocket socket = (SSLSocket) socketFactory.createSocket("localhost",
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org
[tomcat] 04/05: Failed test on Windows. Expand logging to aid
debugging of failures.
Posted by ma...@apache.org.
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
commit e1a7fbc09a72bee3b0f28cd61dd80343ce163635
Author: Mark Thomas <ma...@apache.org>
AuthorDate: Thu Apr 2 21:37:48 2020 +0100
Failed test on Windows. Expand logging to aid debugging of failures.
---
test/org/apache/tomcat/util/net/TestSsl.java | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/test/org/apache/tomcat/util/net/TestSsl.java b/test/org/apache/tomcat/util/net/TestSsl.java
index 1736b49..ae23179 100644
--- a/test/org/apache/tomcat/util/net/TestSsl.java
+++ b/test/org/apache/tomcat/util/net/TestSsl.java
@@ -128,14 +128,17 @@ public class TestSsl extends TomcatBaseTest {
}
}
- for (byte c : bytes) {
+ for (int i = 0; i < bytes.length; i++) {
int read = is.read();
- if (c != read) {
+ if (bytes[i] != read) {
+ System.err.print("Byte in position [" + i + "] had value [" + read +
+ "] rather than " + Byte.toString(bytes[i]));
errorCount.incrementAndGet();
break;
}
}
} catch (Exception e) {
+ e.printStackTrace();
errorCount.incrementAndGet();
} finally {
latch.countDown();
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org