You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by re...@apache.org on 2015/10/29 18:07:56 UTC
svn commit: r1711305 -
/tomcat/trunk/java/org/apache/tomcat/util/net/SecureNio2Channel.java
Author: remm
Date: Thu Oct 29 17:07:56 2015
New Revision: 1711305
URL: http://svn.apache.org/viewvc?rev=1711305&view=rev
Log:
Propagate SSL read timeouts and cancel properly, to be able to cancel the operation if a timeout occurs.
Modified:
tomcat/trunk/java/org/apache/tomcat/util/net/SecureNio2Channel.java
Modified: tomcat/trunk/java/org/apache/tomcat/util/net/SecureNio2Channel.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/tomcat/util/net/SecureNio2Channel.java?rev=1711305&r1=1711304&r2=1711305&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/tomcat/util/net/SecureNio2Channel.java (original)
+++ tomcat/trunk/java/org/apache/tomcat/util/net/SecureNio2Channel.java Thu Oct 29 17:07:56 2015
@@ -574,7 +574,7 @@ public class SecureNio2Channel extends N
private class FutureRead implements Future<Integer> {
private final ByteBuffer dst;
- private final Future<Integer> integer;
+ private Future<Integer> integer;
private FutureRead(ByteBuffer dst) {
this.dst = dst;
if (unwrapBeforeRead || netInBuffer.position() > 0) {
@@ -597,7 +597,12 @@ public class SecureNio2Channel extends N
}
@Override
public Integer get() throws InterruptedException, ExecutionException {
- return (integer == null) ? unwrap(netInBuffer.position(), -1, TimeUnit.MILLISECONDS) : unwrap(integer.get().intValue(), -1, TimeUnit.MILLISECONDS);
+ try {
+ return (integer == null) ? unwrap(netInBuffer.position(), -1, TimeUnit.MILLISECONDS) : unwrap(integer.get().intValue(), -1, TimeUnit.MILLISECONDS);
+ } catch (TimeoutException e) {
+ // Cannot happen: no timeout
+ throw new ExecutionException(e);
+ }
}
@Override
public Integer get(long timeout, TimeUnit unit)
@@ -605,7 +610,7 @@ public class SecureNio2Channel extends N
TimeoutException {
return (integer == null) ? unwrap(netInBuffer.position(), timeout, unit) : unwrap(integer.get(timeout, unit).intValue(), timeout, unit);
}
- private Integer unwrap(int nRead, long timeout, TimeUnit unit) throws ExecutionException {
+ private Integer unwrap(int nRead, long timeout, TimeUnit unit) throws ExecutionException, TimeoutException, InterruptedException {
//are we in the middle of closing or closed?
if (closing || closed)
return Integer.valueOf(-1);
@@ -637,14 +642,11 @@ public class SecureNio2Channel extends N
//if we need more network data, then bail out for now.
if (unwrap.getStatus() == Status.BUFFER_UNDERFLOW) {
if (read == 0) {
- try {
- if (timeout > 0) {
- return unwrap(sc.read(netInBuffer).get(timeout, unit).intValue(), timeout, unit);
- } else {
- return unwrap(sc.read(netInBuffer).get().intValue(), -1, TimeUnit.MILLISECONDS);
- }
- } catch (InterruptedException | TimeoutException e) {
- throw new ExecutionException(e);
+ integer = sc.read(netInBuffer);
+ if (timeout > 0) {
+ return unwrap(integer.get(timeout, unit).intValue(), timeout, unit);
+ } else {
+ return unwrap(integer.get().intValue(), -1, TimeUnit.MILLISECONDS);
}
} else {
break;
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org