cancel the timeout if we fail to send the request
This commit is contained in:
parent
b0c8255cd9
commit
a60e542718
|
@ -174,8 +174,8 @@ public class TransportService extends AbstractLifecycleComponent<TransportServic
|
||||||
public <T extends Streamable> void sendRequest(final DiscoveryNode node, final String action, final Streamable message,
|
public <T extends Streamable> void sendRequest(final DiscoveryNode node, final String action, final Streamable message,
|
||||||
final TimeValue timeout, final TransportResponseHandler<T> handler) throws TransportException {
|
final TimeValue timeout, final TransportResponseHandler<T> handler) throws TransportException {
|
||||||
final long requestId = newRequestId();
|
final long requestId = newRequestId();
|
||||||
|
Timeout timeoutX = null;
|
||||||
try {
|
try {
|
||||||
Timeout timeoutX = null;
|
|
||||||
if (timeout != null) {
|
if (timeout != null) {
|
||||||
timeoutX = timerService.newTimeout(new TimeoutTimerTask(requestId), timeout);
|
timeoutX = timerService.newTimeout(new TimeoutTimerTask(requestId), timeout);
|
||||||
}
|
}
|
||||||
|
@ -185,6 +185,9 @@ public class TransportService extends AbstractLifecycleComponent<TransportServic
|
||||||
// usually happen either because we failed to connect to the node
|
// usually happen either because we failed to connect to the node
|
||||||
// or because we failed serializing the message
|
// or because we failed serializing the message
|
||||||
clientHandlers.remove(requestId);
|
clientHandlers.remove(requestId);
|
||||||
|
if (timeoutX != null) {
|
||||||
|
timeoutX.cancel();
|
||||||
|
}
|
||||||
if (throwConnectException) {
|
if (throwConnectException) {
|
||||||
if (e instanceof ConnectTransportException) {
|
if (e instanceof ConnectTransportException) {
|
||||||
throw (ConnectTransportException) e;
|
throw (ConnectTransportException) e;
|
||||||
|
|
Loading…
Reference in New Issue