Skip to content
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

Conversation

lachlan-roberts
Copy link
Contributor

@lachlan-roberts lachlan-roberts commented Feb 14, 2019

Issue #3341 - XmlBasedHttpClientProvider in Jetty 10

  • HttpClientProvider classes were moved from jetty-websocket-client to websocket-core
  • WebSocketCoreClient now defers to HttpClientProvider to create its HttpClient if it is not given one in its constructor
  • HttpClientProvider now and interface which implements a static method get() and a default method newHttpClient()
  • XmlHttpClientProvider now implements HttpClientProvider

@lachlan-roberts lachlan-roberts force-pushed the jetty-10.0.x-3341-HttpClientProvider branch from caf79b2 to db5dcbd Compare February 14, 2019 01:16
Signed-off-by: Lachlan Roberts <lachlan@webtide.com>
@lachlan-roberts lachlan-roberts force-pushed the jetty-10.0.x-3341-HttpClientProvider branch 2 times, most recently from 4e5aea1 to b0d9a36 Compare February 14, 2019 02:37
- 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>
@lachlan-roberts lachlan-roberts force-pushed the jetty-10.0.x-3341-HttpClientProvider branch from b0d9a36 to 1496205 Compare February 14, 2019 05:15
Copy link
Contributor

@sbordet sbordet left a 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();
Copy link
Contributor

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:

  1. Move the implementation of newHttpClient() to a private static method called newDefaultHttpClient().
  2. 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();
Copy link
Contributor

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>
@sbordet sbordet merged commit 4229082 into jetty:jetty-10.0.x Feb 18, 2019

private static HttpClient newDefaultHttpClient()
{
HttpClient client = new HttpClient(new SslContextFactory());
Copy link
Contributor

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?

Copy link
Contributor Author

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.

@lachlan-roberts lachlan-roberts deleted the jetty-10.0.x-3341-HttpClientProvider branch July 1, 2019 03:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants