Issue #2210 - adding httpclient safety checks.
+ ISE on non started HttpClient + ISE on use of wss:// URI with HttpClient without an SSL config
This commit is contained in:
parent
7374d6563d
commit
9322956512
|
@ -25,6 +25,7 @@ import java.net.URI;
|
|||
import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
import java.util.Locale;
|
||||
import java.util.Objects;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.Executor;
|
||||
import java.util.concurrent.Future;
|
||||
|
@ -368,6 +369,15 @@ public class WebSocketClient extends ContainerLifeCycle implements WebSocketCont
|
|||
throw new IllegalArgumentException("WebSocket URI scheme only supports [ws] and [wss], not [" + scheme + "]");
|
||||
}
|
||||
|
||||
if ("wss".equals(scheme))
|
||||
{
|
||||
// test for ssl context
|
||||
if (httpClient.getSslContextFactory() == null)
|
||||
{
|
||||
throw new IllegalStateException("HttpClient has no SslContextFactory, wss:// URI's are not supported in this configuration");
|
||||
}
|
||||
}
|
||||
|
||||
request.setRequestURI(toUri);
|
||||
request.setLocalEndpoint(websocket);
|
||||
|
||||
|
@ -391,6 +401,17 @@ public class WebSocketClient extends ContainerLifeCycle implements WebSocketCont
|
|||
return wsReq.sendAsync();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void doStart() throws Exception
|
||||
{
|
||||
Objects.requireNonNull(httpClient, "Provided HttpClient is null");
|
||||
|
||||
if (!httpClient.isRunning())
|
||||
throw new IllegalStateException("HttpClient is not running (did you forget to start it?): " + httpClient);
|
||||
|
||||
super.doStart();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void doStop() throws Exception
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue