Make sure that the reset cause of an HttpClient timeout will always happen before the connection close (when it's needed), also make the timeout exception subclass not an inner class

This commit is contained in:
Julien Viet
2019-07-05 17:16:20 +02:00
parent 5413138ea4
commit 44a0a9e9d3
3 changed files with 27 additions and 9 deletions

View File

@@ -370,6 +370,9 @@ class Http1xClientConnection extends Http1xConnectionBase<WebSocketImpl> impleme
return;
}
reset = true;
}
handleException(cause);
synchronized (conn) {
if (conn.requestInProgress == this) {
if (request == null) {
// Is that possible in practice ???
@@ -383,7 +386,6 @@ class Http1xClientConnection extends Http1xConnectionBase<WebSocketImpl> impleme
// ????
}
}
handleException(cause);
}
@Override

View File

@@ -20,8 +20,6 @@ import io.vertx.core.http.HttpMethod;
import io.vertx.core.http.StreamResetException;
import io.vertx.core.net.SocketAddress;
import java.util.concurrent.TimeoutException;
/**
* @author <a href="mailto:julien@julienviet.com">Julien Viet</a>
*/
@@ -139,12 +137,7 @@ public abstract class HttpClientRequestBase implements HttpClientRequest {
}
}
String msg = "The timeout period of " + timeoutMs + "ms has been exceeded while executing " + method + " " + uri + " for server " + server;
reset(new TimeoutException(msg) {
@Override
public synchronized Throwable fillInStackTrace() {
return this;
}
});
reset(new NoStackTraceTimeoutException(msg));
}
synchronized void dataReceived() {

View File

@@ -0,0 +1,23 @@
/*
* Copyright (c) 2011-2019 Contributors to the Eclipse Foundation
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0, or the Apache License, Version 2.0
* which is available at https://www.apache.org/licenses/LICENSE-2.0.
*
* SPDX-License-Identifier: EPL-2.0 OR Apache-2.0
*/
package io.vertx.core.http.impl;
import java.util.concurrent.TimeoutException;
class NoStackTraceTimeoutException extends TimeoutException {
NoStackTraceTimeoutException(String message) {
super(message);
}
@Override
public synchronized Throwable fillInStackTrace() {
return this;
}
}