Uploaded image for project: 'CXF'
  1. CXF
  2. CXF-4710

System properties -Dhttp.nonProxyHosts from maven proxy settings is not filled and has side-effects on jvm

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Closed
    • Major
    • Resolution: Duplicate
    • 2.5.4, 2.5.5, 2.5.6, 2.5.7
    • None
    • Build system
    • None
    • Moderate

    Description

      The System.properties -Dhttp.nonProxyHosts=.... is not set during the Mojo executions, but others parameters for http proxy are set ( useProxy, http.proxyHost, http.proxyPort), resulting in inconsistencies .

      This is particulary annoying when using plugin cxf-maven-plugin and then another plugin in the same jvm, like jetty:run or failsafe/surefire ...

      The bugs occurs for example in mvn jetty:run after, doing a HttpURLConnection, with exception like "407 Proxy authentication required" while trying to access a http resource within the intranet, that should have by-passed the proxy but which is not due to missing -Dhttp.nonProxyHosts. Notice that to reproduce the problem, you must have a very restrictive proxy with authentication (like ntlm), and the bug occurs because credentials user/password are also not set passed from maven to the jvm.

      The bug is in cxf-codegen-plugin/src/main/java/org/apache/cxf/maven_plugin/AbstractCodegenMoho.java

      line 332
      The following line is missing :

      System.setProperty("http.nonProxyHosts", String.valueOf(proxy.getNonProxyHosts()));

      Remarks:
      1) to avoid side-effects on the current jvm, you could also restore previous value in a try-finally :

      String PROP = "http.nonProxyHosts"; // cf also http.proxyHost ..
      String requiredPropValue = "localhost|*.mydomain";
      String oldPropertyValue = System.getProperty(PROP);
      if (!requiredPropValue.equals(oldPropertyValue))

      { // temporary change property System.setProperty(PROP, requiredPropValue); }

      try

      { // *** do work in cxf-plugin *** }

      finally {
      // restore old property value
      if (!requiredPropValue.equals(oldPropertyValue))

      { System.setProperty(PROP, oldPropertyValue); }

      }

      2) You should also use the credentials login/password in case of authenticating proxy...

      Attachments

        Issue Links

          Activity

            People

              ffang Freeman Yue Fang
              nauwynck Arnaud Nauwynck
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Time Tracking

                  Estimated:
                  Original Estimate - 2h
                  2h
                  Remaining:
                  Remaining Estimate - 2h
                  2h
                  Logged:
                  Time Spent - Not Specified
                  Not Specified