[ 
https://issues.apache.org/jira/browse/SOLR-17464?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17885434#comment-17885434
 ] 

Jason Gerlowski commented on SOLR-17464:
----------------------------------------

One potential fix would be for the "reuse" codepath to populate 
Http2SolrClient's "executor" field with the value of "httpClient.getExecutor()" 
[here|https://github.com/apache/solr/blob/ee5c9bedf06999c4287414ac2a9ff81c068f7caf/solr/solrj/src/java/org/apache/solr/client/solrj/impl/Http2SolrClient.java#L129-L131].
  There's a slight hiccup to this, in that "httpClient.getExecutor()" returns 
an "Executor", but Http2SolrClient currently requires an "ExecutorService".  
But perhaps casting would be safe here, since all reused Jetty client's come 
from an existing Http2SolrClient?

> Http2SolrClient.requestAsync triggers NPE when using a shared Jetty client
> --------------------------------------------------------------------------
>
>                 Key: SOLR-17464
>                 URL: https://issues.apache.org/jira/browse/SOLR-17464
>             Project: Solr
>          Issue Type: Bug
>      Security Level: Public(Default Security Level. Issues are Public) 
>    Affects Versions: main (10.0), 9.7
>            Reporter: Jason Gerlowski
>            Priority: Major
>              Labels: newdev
>
> Http2SolrClient can be configured to either create its own Jetty HttpClient, 
> or reuse an existing one.
> In this latter "reuse" case, the Http2SolrClient never sets the "executor" 
> instance variable.  This causes a NullPointerException any time the 
> SolrClient's "requestAsync" method is called, which expects "executor" to be 
> set.
> The bug is easy to reproduce with the following JUnit code (that, as of 
> writing, can be dropped into Http2SolrClientTest and run):
> {code}
>   @Test
>   public void testReproduceExecutorNPEBug() {
>     DebugServlet.clear();
>     final var url = getBaseUrl() + DEBUG_SERVLET_PATH;
>     final var queryParams = new ModifiableSolrParams();
>     queryParams.add("q", "*:*");
>     try (Http2SolrClient originalClient = new 
> Http2SolrClient.Builder(url).withDefaultCollection(DEFAULT_CORE).build()) {
>       // TODO The 'requestAsync' call below should succeed, but produces an 
> NPE since 
>       try (Http2SolrClient derivedClient = new 
> Http2SolrClient.Builder(url).withDefaultCollection(DEFAULT_CORE).withHttpClient(originalClient).build())
>  {
>         final var future = derivedClient.requestAsync(new 
> QueryRequest(queryParams));
>         final var results = future.join();
>       }
>     }
>   }
> {code}
> And the exception:
> {code}
> 3429 INFO  (h2sc-21-thread-2) [n: c: s: r: x: t:] o.e.j.c.ResponseNotifier 
> Exception while notifying listener 
> org.apache.solr.client.solrj.impl.Http2SolrClient$1@34bcd66e
>           => java.lang.NullPointerException: Cannot invoke 
> "java.util.concurrent.ExecutorService.execute(java.lang.Runnable)" because 
> "this.this$0.executor" is null
>       at 
> org.apache.solr.client.solrj.impl.Http2SolrClient$1.onHeaders(Http2SolrClient.java:447)
> java.lang.NullPointerException: Cannot invoke 
> "java.util.concurrent.ExecutorService.execute(java.lang.Runnable)" because 
> "this.this$0.executor" is null
>       at 
> org.apache.solr.client.solrj.impl.Http2SolrClient$1.onHeaders(Http2SolrClient.java:447)
>  ~[main/:?]
>       at 
> org.eclipse.jetty.client.ResponseNotifier.notifyHeaders(ResponseNotifier.java:95)
>  [jetty-client-10.0.22.jar:10.0.22]
>       at 
> org.eclipse.jetty.client.ResponseNotifier.notifyHeaders(ResponseNotifier.java:87)
>  [jetty-client-10.0.22.jar:10.0.22]
>       at 
> org.eclipse.jetty.client.HttpReceiver.responseHeaders(HttpReceiver.java:327) 
> [jetty-client-10.0.22.jar:10.0.22]
>       at 
> org.eclipse.jetty.http2.client.http.HttpReceiverOverHTTP2.onHeaders(HttpReceiverOverHTTP2.java:120)
>  [http2-http-client-transport-10.0.22.jar:10.0.22]
>       at 
> org.eclipse.jetty.http2.client.http.HttpChannelOverHTTP2$Listener.onHeaders(HttpChannelOverHTTP2.java:186)
>  [http2-http-client-transport-10.0.22.jar:10.0.22]
> ...
> {code}



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscr...@solr.apache.org
For additional commands, e-mail: issues-h...@solr.apache.org

Reply via email to