-
Notifications
You must be signed in to change notification settings - Fork 1.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Issue #3341 - WebSocket HttpClientProvider #3357
Issue #3341 - WebSocket HttpClientProvider #3357
Conversation
caf79b2
to
db5dcbd
Compare
Signed-off-by: Lachlan Roberts <lachlan@webtide.com>
4e5aea1
to
b0d9a36
Compare
- HttpClientProvider is now an interface which defines a default method newHttpClient, its static get() method get will attempt to use the XmlHttpClientProvider to create a client, and if this fails to give a non null client it will be created with the default newHttpClient method Signed-off-by: Lachlan Roberts <lachlan@webtide.com>
b0d9a36
to
1496205
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just do this one last change I asked, the rest looks good.
Log.getLogger(HttpClientProvider.class).ignore(ignore); | ||
} | ||
|
||
return new HttpClientProvider(){}.newHttpClient(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's use one more feature of interfaces.
They can now have private static methods, so:
- Move the implementation of
newHttpClient()
to a private static method callednewDefaultHttpClient()
. - Here, rather than creating a new anonymous implementation, just call the private static method.
{ | ||
HttpClient client = new HttpClient(new SslContextFactory()); | ||
QueuedThreadPool threadPool = new QueuedThreadPool(); | ||
threadPool.setName("WebSocketClient@" + client.hashCode()); | ||
client.setExecutor(threadPool); | ||
return client; | ||
} | ||
|
||
HttpClient newHttpClient(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This method should be implemented by calling newDefaultHttpClient()
.
In this way, subclasses can call super
, obtain the default instance and further customize it.
Signed-off-by: Lachlan Roberts <lachlan@webtide.com>
0104e37
to
d8b5f0e
Compare
|
||
private static HttpClient newDefaultHttpClient() | ||
{ | ||
HttpClient client = new HttpClient(new SslContextFactory()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note that we were previously setting setEndpointIdentificationAlgorithm("HTTPS"). Should we still do that or has it been changed to the default now?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes the endpointIdentificationAlgorithm
now defaults to "HTTPS" in the SslContextFactory
.
I had this line in previously but @sbordet said it was not needed.
Issue #3341 - XmlBasedHttpClientProvider in Jetty 10
HttpClientProvider
classes were moved from jetty-websocket-client to websocket-coreWebSocketCoreClient
now defers toHttpClientProvider
to create itsHttpClient
if it is not given one in its constructorHttpClientProvider
now and interface which implements a static methodget()
and a default methodnewHttpClient()
XmlHttpClientProvider
now implementsHttpClientProvider