This is an automated email from the ASF dual-hosted git repository.
remm pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/tomcat.git
The following commit(s) were added to refs/heads/master by this push:
new 256e9a0 Avoid useless exception wrapping in async IO
256e9a0 is described below
commit 256e9a03005fa421a1924d0d33942436c5ca20e5
Author: remm <[email protected]>
AuthorDate: Wed May 8 00:36:50 2019 +0200
Avoid useless exception wrapping in async IO
---
java/org/apache/coyote/http2/Http2AsyncParser.java | 2 ++
java/org/apache/tomcat/util/net/Nio2Endpoint.java | 7 +++----
java/org/apache/tomcat/util/net/NioEndpoint.java | 7 +++----
webapps/docs/changelog.xml | 3 +++
4 files changed, 11 insertions(+), 8 deletions(-)
diff --git a/java/org/apache/coyote/http2/Http2AsyncParser.java
b/java/org/apache/coyote/http2/Http2AsyncParser.java
index 92bf09f..827105a 100644
--- a/java/org/apache/coyote/http2/Http2AsyncParser.java
+++ b/java/org/apache/coyote/http2/Http2AsyncParser.java
@@ -152,6 +152,8 @@ class Http2AsyncParser extends Http2Parser {
throw (Http2Exception) error;
} else if (error instanceof IOException) {
throw (IOException) error;
+ } else if (error instanceof RuntimeException) {
+ throw (RuntimeException) error;
} else {
throw new RuntimeException(error);
}
diff --git a/java/org/apache/tomcat/util/net/Nio2Endpoint.java
b/java/org/apache/tomcat/util/net/Nio2Endpoint.java
index 815713a..a4844bc 100644
--- a/java/org/apache/tomcat/util/net/Nio2Endpoint.java
+++ b/java/org/apache/tomcat/util/net/Nio2Endpoint.java
@@ -1189,13 +1189,12 @@ public class Nio2Endpoint extends
AbstractJsseEndpoint<Nio2Channel,AsynchronousS
}
@Override
public void failed(Throwable exc, OperationState<A> state) {
- IOException ioe;
+ IOException ioe = null;
if (exc instanceof InterruptedByTimeoutException) {
ioe = new SocketTimeoutException();
+ exc = ioe;
} else if (exc instanceof IOException) {
ioe = (IOException) exc;
- } else {
- ioe = new IOException(exc);
}
setError(ioe);
boolean notify = false;
@@ -1206,7 +1205,7 @@ public class Nio2Endpoint extends
AbstractJsseEndpoint<Nio2Channel,AsynchronousS
state.state = Nio2Endpoint.isInline() ?
CompletionState.ERROR : CompletionState.DONE;
}
if (state.handler != null) {
- state.handler.failed(ioe, state.attachment);
+ state.handler.failed(exc, state.attachment);
}
if (notify) {
synchronized (state) {
diff --git a/java/org/apache/tomcat/util/net/NioEndpoint.java
b/java/org/apache/tomcat/util/net/NioEndpoint.java
index 02fb854..a087ed8 100644
--- a/java/org/apache/tomcat/util/net/NioEndpoint.java
+++ b/java/org/apache/tomcat/util/net/NioEndpoint.java
@@ -1763,13 +1763,12 @@ public class NioEndpoint extends
AbstractJsseEndpoint<NioChannel,SocketChannel>
}
@Override
public void failed(Throwable exc, OperationState<A> state) {
- IOException ioe;
+ IOException ioe = null;
if (exc instanceof InterruptedByTimeoutException) {
ioe = new SocketTimeoutException();
+ exc = ioe;
} else if (exc instanceof IOException) {
ioe = (IOException) exc;
- } else {
- ioe = new IOException(exc);
}
setError(ioe);
boolean notify = false;
@@ -1785,7 +1784,7 @@ public class NioEndpoint extends
AbstractJsseEndpoint<NioChannel,SocketChannel>
state.state = state.inline ? CompletionState.ERROR :
CompletionState.DONE;
}
if (state.handler != null) {
- state.handler.failed(ioe, state.attachment);
+ state.handler.failed(exc, state.attachment);
}
synchronized (state) {
state.completionDone = true;
diff --git a/webapps/docs/changelog.xml b/webapps/docs/changelog.xml
index be3a473..1a2085c 100644
--- a/webapps/docs/changelog.xml
+++ b/webapps/docs/changelog.xml
@@ -77,6 +77,9 @@
<bug>63403</bug>: Fix TestHttp2InitialConnection test failures when
running with a non-English locale. (kkolinko)
</fix>
+ <fix>
+ Avoid useless exception wrapping in async IO. (remm)
+ </fix>
</changelog>
</subsection>
</section>
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]