Uploaded image for project: 'Jira Data Center'
  1. Jira Data Center
  2. JRASERVER-63759

BaseUrlHealthCheck will fail when system configuration goes through more than 3 redirects

    XMLWordPrintable

Details

    Description

      Summary

      The BaseUrlHealthCheck will fail when the environment goes through more than 3 redirects. This can happen with complex proxies or some plugins such as SAML authentication that goes through multiple redirections.

      Steps to Reproduce

      1. Set up a JIRA instance with multiple redirections (e.g. set up SAML with redirection)
      2. Run the JIRA health check

      Expected Results

      The base URL is configured properly, so the test passes

      Actual Results

      The below exception is thrown in the atlassian-jira.log file:

      2017-01-09 16:27:47,254 SupportHealthCheckThread-5 ERROR ServiceRunner     [c.a.j.p.healthcheck.support.BaseUrlHealthCheck] An error occurred when performing the Base URL healthcheck: 
      org.apache.http.client.ClientProtocolException
      	at org.apache.http.impl.client.InternalHttpClient.doExecute(InternalHttpClient.java:186)
      	at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:82)
      	at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:107)
      	at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:55)
      	at com.atlassian.jira.plugins.healthcheck.support.BaseUrlHealthCheck.doCheck(BaseUrlHealthCheck.java:52)
      	at com.atlassian.jira.plugins.healthcheck.support.AbstractSupportHealthCheck.check(AbstractSupportHealthCheck.java:27)
      	at com.atlassian.support.healthcheck.impl.PluginSuppliedSupportHealthCheck.check(PluginSuppliedSupportHealthCheck.java:41)
      	at com.atlassian.support.healthcheck.concurrent.SupportHealthCheckTask.run(SupportHealthCheckTask.java:33)
      	at com.atlassian.support.healthcheck.concurrent.SupportHealthCheckProcess.run(SupportHealthCheckProcess.java:43)
      	at com.atlassian.support.healthcheck.thread.HealthCheckProcessCallable.call(HealthCheckProcessCallable.java:44)
      	at com.atlassian.support.healthcheck.thread.HealthCheckProcessCallable.call(HealthCheckProcessCallable.java:20)
      	at java.util.concurrent.FutureTask.run(FutureTask.java:266)
      	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
      	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
      	at java.lang.Thread.run(Thread.java:745)
      Caused by: org.apache.http.client.RedirectException: Maximum redirects (3) exceeded
      

      Notes

      The BaseUrlHealthCheck.java class in the jira-healthcheck-plugin is hardcoding the value to 3 (setMaxRedirects(3)), which is not adequate for all customers:

          private HttpClient newHttpClient() {
              SocketConfig socketConfig = SocketConfig.custom().setSoTimeout(DEFAULT_CONNECT_TIMEOUT_MS).build();
              HttpClientBuilder httpClientBuilder = HttpClientBuilder.create();
      
              SystemDefaultRoutePlanner routePlanner = new SystemDefaultRoutePlanner(ProxySelector.getDefault());
              httpClientBuilder.setRoutePlanner(routePlanner);
              httpClientBuilder.setDefaultSocketConfig(socketConfig);
              httpClientBuilder.setDefaultHeaders(
                      ImmutableSet.of(new BasicHeader("Accept-Encoding", "gzip, deflate"))
              );
      
              RequestConfig.Builder requestConfigBuilder = RequestConfig.custom().setMaxRedirects(3);
              httpClientBuilder.setDefaultRequestConfig(requestConfigBuilder.build());
      
              return httpClientBuilder.build();
          }
      }

      Diagnosis

      If you run the httpclienttest that is used by this class, you will notice the connection is successful but there are more than 3 redirections happening. This causes the check to fail.

      grep -c "Redirect requested" /Users/ajean/Desktop/http-client-test.out
      4

      In this specific case, since the number is above 3, it will cause the check to fail even though the base URL is correct.

      Workaround

      Remove complex redirections from the environment (not optimal)

      Attachments

        Issue Links

          Activity

            People

              dcurrie@atlassian.com Dave C
              ajean Andy J.
              Votes:
              0 Vote for this issue
              Watchers:
              7 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: