Uploaded image for project: 'Jenkins'
  1. Jenkins
  2. JENKINS-53125

Setting CookieManager causes issues with other plugins

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Minor Minor
    • None
    • Jenkins 2.121.3, parametrized-remote-trigger-plugin > v3.0.3, Java 1.8.181, redhat 7, hpe-application-automation-tools-plugin 5.4.

      Hello everyone,

      we faced conflict between 2 plugins and some code we using to deploy applications.

      It seems that after installing parametrized-remote-trigger-plugin plugin hpe-application-automation-tools-plugin and some other code stop working with the following error:

      Start login to ALM server.Failed login to ALM Server URL: <ALM URL HERE>. Exception: com.hpe.application.automation.tools.common.SSEException: java.lang.StringIndexOutOfBoundsException: String index out of range: -1Empty Results

      We've done some research and found that this example code stops working:

      import java.io.IOException;
      import java.net.HttpURLConnection;
      import java.net.MalformedURLException;
      import java.net.URL;
      import java.net.URLConnection;
      import java.util.logging.Level;
      import java.util.logging.Logger;
       
      u = new URL("http://<ALM URL HERE>/qcbin/authentication-point/authenticate");
       
      connection = (HttpURLConnection) u.openConnection();
      connection.setRequestMethod("GET");
      connection.setRequestProperty("Authorization", "Basic <base64 USER:PASS> ");
      println("RC = " + connection.getResponseCode());
      println(connection.getHeaderFields());
      println(connection.getHeaderField("Set-Cookie"));

      It returns empty results from Set-Cookie header.

      If we run similar code with separate process on the same server with same java version and everything was ok and we got cookie from Set-Cookie header. But if this code run from jenkins script console - it doesn't work.

      Almost the similar code used in hpe-application-automation-tools-plugin to perform authentication and get session cookie, so it stop working to.

      Next we found that setting CookieHandeler to null restores all functionality:

      java.net.CookieHandler.setDefault(null)
      

      Finally we checked installed plugins source code for setting CookieHandler and found it in parametrized-remote-trigger-plugin staring from 3.0.3 version here:  https://github.com/jenkinsci/parameterized-remote-trigger-plugin/blob/093a3d8244a383e815684f7c6bfe5fcaf06c8da7/src/main/java/org/jenkinsci/plugins/ParameterizedRemoteTrigger/utils/HttpHelper.java#L384

      it the static block.

      Im not a java programmer, but I guess this block runs just once at startup, and resetting CookieHandeler fixes until restart.

       

       

       

       

       

       

            cashlalala KaiHsiang Chang
            berestoff veniamin b
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: