Uploaded image for project: 'Solr'
  1. Solr
  2. SOLR-16367 Umbrella: Migrate away from Apache HttpClient.
  3. SOLR-17300

Copy existing listeners on re-creation of Http2SolrClient

Attach filesAttach ScreenshotVotersWatch issueWatchersLinkCloneUpdate Comment AuthorReplace String in CommentUpdate Comment VisibilityDelete Comments
    XMLWordPrintableJSON

Details

    • Sub-task
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • None
    • 9.7
    • None
    • None

    Description

      For custom settings, such as timeouts, usually a Http2SolrClient is created using the existing HTTP client using below code.

      Http2SolrClient.Builder(leaderBaseUrl)
                  .withHttpClient(existingHttp2SolrClient)
                  .withIdleTimeout(soTimeout, TimeUnit.MILLISECONDS)
                  .withConnectionTimeout(connTimeout, TimeUnit.MILLISECONDS)
                  .build();
      

      If not specified, withHttpClient method would automatically copy over some of the older configuration automatically to the new Http2SolrClient

      if (this.basicAuthAuthorizationStr == null) {
              this.basicAuthAuthorizationStr = http2SolrClient.basicAuthAuthorizationStr;
            }
            if (this.followRedirects == null) {
              this.followRedirects = http2SolrClient.httpClient.isFollowRedirects();
            }
            if (this.idleTimeoutMillis == null) {
              this.idleTimeoutMillis = http2SolrClient.idleTimeoutMillis;
            }
            if (this.requestWriter == null) {
              this.requestWriter = http2SolrClient.requestWriter;
            }
            if (this.requestTimeoutMillis == null) {
              this.requestTimeoutMillis = http2SolrClient.requestTimeoutMillis;
            }
            if (this.responseParser == null) {
              this.responseParser = http2SolrClient.parser;
            }
            if (this.urlParamNames == null) {
              this.urlParamNames = http2SolrClient.urlParamNames;
            }
      

      Nonetheless there is one field that did not pass over yet – List of HttpListenerFactory. This list also includes the interceptor for Auth due to which re-created client were missing auth credentials and requests were failing.

      Proposed Solution :-

      Along with other properties, List of Listener Factory should also be copied over from old to new client using withHttpClient method.

      if (this.listenerFactory == null) {
              this.listenerFactory = new ArrayList<HttpListenerFactory>();
              http2SolrClient.listenerFactory.forEach(this.listenerFactory::add);
            }
      

      Attachments

        Activity

          This comment will be Viewable by All Users Viewable by All Users
          Cancel

          People

            sanjaydutt Sanjay Dutt
            sanjaydutt Sanjay Dutt
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Time Tracking

                Estimated:
                Original Estimate - Not Specified
                Not Specified
                Remaining:
                Remaining Estimate - 0h
                0h
                Logged:
                Time Spent - 1h 50m
                1h 50m

                Slack

                  Issue deployment