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

SolrJ deleteById doesn't work when authentication is active.

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 5.5.5, 7.2.1, 7.3.1
    • None
    • Authentication
    • None

    Description

      When solr authentication is active the following code fails:

      String id = "xxx"; // same as List<String> ids = ...
      
      UpdateRequest upReq = new UpdateRequest();
      
      upReq.setBasicAuthCredentials("user", "pwd");
      
      upReq.deleteById(id).process(solrClient);
      

      The error is (using solrj 5.5.5):

      org.apache.solr.client.solrj.impl.CloudSolrClient$RouteException: Error from server at http://xxx_shard1_replica_n1: Expected mime type application/xml but got text/html. <html>
      <head>
      <meta http-equiv="Content-Type" content="text/html;charset=utf-8"/>
      <title>Error 401 require authentication</title>
      </head>
      <body><h2>HTTP ERROR 401</h2>
      <p>Problem accessing /solr/XXX_shard1_replica_n1/update. Reason:
      <pre> require authentication</pre></p>
      </body>
      </html>

      org.apache.solr.client.solrj.impl.CloudSolrClient.directUpdate(CloudSolrClient.java:653)
      org.apache.solr.client.solrj.impl.CloudSolrClient.sendRequest(CloudSolrClient.java:1002)
      org.apache.solr.client.solrj.impl.CloudSolrClient.requestWithRetryOnStaleState(CloudSolrClient.java:891)
      org.apache.solr.client.solrj.impl.CloudSolrClient.request(CloudSolrClient.java:827)
      org.apache.solr.client.solrj.SolrRequest.process(SolrRequest.java:149)
      org.apache.solr.client.solrj.SolrRequest.process(SolrRequest.java:166)

      The bug is in the method

      Map<String, Req> org.apache.solr.client.solrj.request.UpdateRequest.getRoutes(DocRouter router, DocCollection col, Map<String, List<String>> urlMap, ModifiableSolrParams params, String idField)

      At line 299 a new request is created without the credentials of the main request.

      Also solrj 7.3.1 is affected by the bug.

      Attachments

        Issue Links

          Activity

            People

              Unassigned Unassigned
              f.grillini@kion.it Federico Grillini
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: