Avoiding NPEs when using ClientConnector directly.

Signed-off-by: Simone Bordet <simone.bordet@gmail.com>
This commit is contained in:
Simone Bordet 2019-07-31 15:30:18 +02:00
parent ffd8e303f1
commit 6753b43d41
1 changed files with 4 additions and 2 deletions

View File

@ -274,6 +274,7 @@ public class ClientConnector extends ContainerLifeCycle
LOG.debug("Could not accept {}", channel); LOG.debug("Could not accept {}", channel);
safeClose(channel); safeClose(channel);
Promise<?> promise = (Promise<?>)context.get(CONNECTION_PROMISE_CONTEXT_KEY); Promise<?> promise = (Promise<?>)context.get(CONNECTION_PROMISE_CONTEXT_KEY);
if (promise != null)
promise.failed(failure); promise.failed(failure);
} }
} }
@ -301,6 +302,7 @@ public class ClientConnector extends ContainerLifeCycle
if (LOG.isDebugEnabled()) if (LOG.isDebugEnabled())
LOG.debug("Could not connect to {}", context.get(REMOTE_SOCKET_ADDRESS_CONTEXT_KEY)); LOG.debug("Could not connect to {}", context.get(REMOTE_SOCKET_ADDRESS_CONTEXT_KEY));
Promise<?> promise = (Promise<?>)context.get(CONNECTION_PROMISE_CONTEXT_KEY); Promise<?> promise = (Promise<?>)context.get(CONNECTION_PROMISE_CONTEXT_KEY);
if (promise != null)
promise.failed(failure); promise.failed(failure);
} }