-
Notifications
You must be signed in to change notification settings - Fork 701
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
SOLR-17688: Http2SolrClient: use Request.Listener not HttpListenerFactory #3233
base: main
Are you sure you want to change the base?
Conversation
and remove HttpListenerFactory. HTTP request listeners live in HttpClient now, not Http2SolrClient. Lifecycle is different. Expose HttpClient from Http2SolrClient.
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.
A test run passed. But a previous run without substantive changes failed in JWTAuthPluginIntegrationTest
and TestTaskManagement
; don't know why yet. The former is relevant to these changes (auth stuff). I'll want to do more testing to get more confidence.
@@ -377,8 +376,8 @@ PublicKey fetchPublicKeyFromRemote(String nodename) { | |||
|
|||
@Override | |||
public void setup(Http2SolrClient client) { | |||
final HttpListenerFactory.RequestResponseListener listener = | |||
new HttpListenerFactory.RequestResponseListener() { | |||
final var listener = |
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 listener no per-request state so can simply add this listener to client level.
TraceUtils.injectTraceContext(request); | ||
} | ||
public final void onQueued(Request req) { | ||
var listener = new PerRequestListener(req); |
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 scenario is maybe a bit more awkward because on onQueued, we need to register a listener specific for this request because the listener has per-request state (fields). This was previously happening for all listeners in Http2SolrClient but you'll see it gets removed there now.
@@ -632,12 +613,6 @@ private void decorateRequest(Request req, SolrRequest<?> solrRequest, boolean is | |||
} | |||
|
|||
setBasicAuthHeader(solrRequest, req); | |||
for (HttpListenerFactory factory : listenerFactory) { |
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.
No longer need to do this; the listeners are now at httpClient level, not request level. Granted the listener onQueued can choose to register another listener (and one does do this).
@@ -95,10 +95,9 @@ public void setup(Http2SolrClient client, String basicAuthUser, String basicAuth | |||
authenticationStore.addAuthentication( | |||
new SolrBasicAuthentication(basicAuthUser, basicAuthPass)); | |||
client.setAuthenticationStore(authenticationStore); | |||
client.getProtocolHandlers().put(new WWWAuthenticationProtocolHandler(client.getHttpClient())); |
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.
because I removed client.getProtocolHandlers() now that HttpClient is exposed
The JWT test failure isn't related to this PR, I think; the same error occurred previously. |
Planning to merge Tuesday. Beforehand will look closer at the errors that I did see, which seemed intermittent and unrelated.
|
interesting change, I think it looks good and the new version of the code looks much cleaner, +1 from me. just 2 thoughts (feel free to ignore if not relevant):
|
Thanks for your feedback Alex!
I think this will be less of an issue now because the HttpClient (thus everything attached to it) goes along for the ride. This PR shows that we no longer need to copy them when the httpClient is provided in the builder. But I suppose that if a user creates an HttpClient on their own for whatever reason, then the onus is on them to configure it with whatever listeners are desired; previously this was separate. But that's true with all the other settings in the builder associated with the HttpClient construction (e.g. everything createHttpClient looks at in the builder). It underscores a point that if you provide an HttpClient to the builder, it's an expert use-case; you know what you are doing because we don't document every last setting, wether it applies or not if someone provides the client.
I've only seen one switch in the project's history (Apache -> Jetty) so I don't think it's worth insulating the differences. New abstractions are not free; abstractions should be documented as well; don't benefit from knowledge the user might already have in Jetty and they can get in the way. I'd rather see Solr reduce code wherever it can; removing frivolous abstractions is one. Solr's listener factory thing being removed here doesn't apply to the HttpJdkSolrClient (or else you'd have seen the impact in your review). |
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.
Awesome - this looks like a nice little cleanup!
I've hit a blocking test failure in which https://issues.apache.org/jira/browse/SOLR-13510 has reappeared here because onQueued isn't necessarily called from the submitting thread :-( |
and remove HttpListenerFactory. HTTP request listeners live in HttpClient now, not Http2SolrClient. Lifecycle is different. Expose HttpClient from Http2SolrClient.
https://issues.apache.org/jira/browse/SOLR-17688
From JIRA:
10.0 only.