Uploaded image for project: 'Solr'
  1. Solr
  2. SOLR-13921

Processing UpdateRequest with delegation token throws NullPointerException

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Minor
    • Resolution: Fixed
    • 7.4, 7.5, 7.6, 7.7, 7.7.1, 7.7.2, 8.0, 8.1, 8.2, 8.3
    • 8.4
    • SolrJ
    • None

    Description

      When sending UpdateRequests with delegation tokens to Solr using SolrJ, the createMethod of DelegationTokenHttpSolrClient will throw a NullPointerException:

       

        [junit4] ERROR   3.41s | TestSolrCloudWithDelegationTokens.testDelegationTokenSolrClientWithUpdateRequests <<<
         [junit4]    > Throwable #1: java.lang.NullPointerException
         [junit4]    > 	at __randomizedtesting.SeedInfo.seed([B9AE8E4E0CDF1B3D:DBA0B722C813061D]:0)
         [junit4]    > 	at org.apache.solr.client.solrj.impl.DelegationTokenHttpSolrClient.createMethod(DelegationTokenHttpSolrClient.java:93)
         [junit4]    > 	at org.apache.solr.client.solrj.impl.HttpSolrClient.request(HttpSolrClient.java:258)
         [junit4]    > 	at org.apache.solr.client.solrj.impl.HttpSolrClient.request(HttpSolrClient.java:249)
         [junit4]    > 	at org.apache.solr.cloud.TestSolrCloudWithDelegationTokens.doSolrRequest(TestSolrCloudWithDelegationTokens.java:246)
         [junit4]    > 	at org.apache.solr.cloud.TestSolrCloudWithDelegationTokens.testDelegationTokenSolrClientWithUpdateRequests(TestSolrCloudWithDelegationTokens.java:477)
         [junit4]    > 	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
         [junit4]    > 	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
         [junit4]    > 	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
         [junit4]    > 	at java.base/java.lang.reflect.Method.invoke(Method.java:566)
         [junit4]    > 	at java.base/java.lang.Thread.run(Thread.java:834) 

      This happens to all SolrJ clients including the Spark Crunch indexer which use Delegation Tokens and do not specify commit / optimize commands.

      The cause seems to be a missing null check before dereferencing 'params'. The intention of the code seems to be verifying if the delegation token is passed a parameter of the SolrRequest (which is not supported), however the check fails with NPE if the request has no params at all. For update requests which do commit or optimize, the setCommand method initializes the params so no NPE is thrown.

      @Override
        protected HttpRequestBase createMethod(final SolrRequest request, String collection) throws IOException, SolrServerException {
          SolrParams params = request.getParams();
          if (params.getParams(DELEGATION_TOKEN_PARAM) != null) {
            throw new IllegalArgumentException(DELEGATION_TOKEN_PARAM + " parameter not supported");
          }
          return super.createMethod(request, collection);
        }
      

      Attachments

        1. SOLR-13921.patch
          6 kB
          Kevin Risden

        Activity

          People

            krisden Kevin Risden
            warper Istvan Farkas
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: