Fixes #1259 - HostnameVerificationTest.simpleGetWithHostnameVerificationEnabledTest is broken.
When a fill() triggered by a flush() throws, now the write flusher is failed rather than completed. This ensures that both the read and the write side see the same exception, rather than the write side seeing a ClosedChannelException.
This commit is contained in:
parent
ce4c48a877
commit
ddc63066fc
|
@ -19,7 +19,6 @@
|
|||
package org.eclipse.jetty.client;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.nio.channels.ClosedChannelException;
|
||||
import java.security.cert.CertificateException;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
|
||||
|
@ -48,13 +47,17 @@ import org.junit.Test;
|
|||
public class HostnameVerificationTest
|
||||
{
|
||||
private SslContextFactory clientSslContextFactory = new SslContextFactory();
|
||||
private Server server = new Server();
|
||||
private Server server;
|
||||
private HttpClient client;
|
||||
private NetworkConnector connector;
|
||||
|
||||
@Before
|
||||
public void setUp() throws Exception
|
||||
{
|
||||
QueuedThreadPool serverThreads = new QueuedThreadPool();
|
||||
serverThreads.setName("server");
|
||||
server = new Server(serverThreads);
|
||||
|
||||
SslContextFactory serverSslContextFactory = new SslContextFactory();
|
||||
serverSslContextFactory.setKeyStorePath("src/test/resources/keystore.jks");
|
||||
serverSslContextFactory.setKeyStorePassword("storepwd");
|
||||
|
@ -75,10 +78,10 @@ public class HostnameVerificationTest
|
|||
clientSslContextFactory.setKeyStorePath("src/test/resources/keystore.jks");
|
||||
clientSslContextFactory.setKeyStorePassword("storepwd");
|
||||
|
||||
QueuedThreadPool executor = new QueuedThreadPool();
|
||||
executor.setName(executor.getName() + "-client");
|
||||
QueuedThreadPool clientThreads = new QueuedThreadPool();
|
||||
clientThreads.setName("client");
|
||||
client = new HttpClient(clientSslContextFactory);
|
||||
client.setExecutor(executor);
|
||||
client.setExecutor(clientThreads);
|
||||
client.start();
|
||||
}
|
||||
|
||||
|
|
|
@ -514,6 +514,7 @@ public class SslConnection extends AbstractConnection
|
|||
{
|
||||
synchronized (this)
|
||||
{
|
||||
Throwable failure = null;
|
||||
try
|
||||
{
|
||||
// Do we already have some decrypted data?
|
||||
|
@ -708,6 +709,7 @@ public class SslConnection extends AbstractConnection
|
|||
catch (SSLHandshakeException x)
|
||||
{
|
||||
notifyHandshakeFailed(_sslEngine, x);
|
||||
failure = x;
|
||||
throw x;
|
||||
}
|
||||
catch (SSLException x)
|
||||
|
@ -717,6 +719,12 @@ public class SslConnection extends AbstractConnection
|
|||
x = (SSLException)new SSLHandshakeException(x.getMessage()).initCause(x);
|
||||
notifyHandshakeFailed(_sslEngine, x);
|
||||
}
|
||||
failure = x;
|
||||
throw x;
|
||||
}
|
||||
catch (Throwable x)
|
||||
{
|
||||
failure = x;
|
||||
throw x;
|
||||
}
|
||||
finally
|
||||
|
@ -725,7 +733,7 @@ public class SslConnection extends AbstractConnection
|
|||
if (_flushRequiresFillToProgress)
|
||||
{
|
||||
_flushRequiresFillToProgress = false;
|
||||
getExecutor().execute(_runCompletWrite);
|
||||
getExecutor().execute(failure == null ? _runCompletWrite : new FailFlusher(failure));
|
||||
}
|
||||
|
||||
if (_encryptedInput != null && !_encryptedInput.hasRemaining())
|
||||
|
@ -1080,5 +1088,21 @@ public class SslConnection extends AbstractConnection
|
|||
{
|
||||
return super.toString()+"->"+getEndPoint().toString();
|
||||
}
|
||||
|
||||
private class FailFlusher implements Runnable
|
||||
{
|
||||
private final Throwable failure;
|
||||
|
||||
private FailFlusher(Throwable failure)
|
||||
{
|
||||
this.failure = failure;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
getWriteFlusher().onFail(failure);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue