• Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Critical Critical
    • other
    • None
    • Platform: All, OS: Windows XP

      On Windows you get an NPE in the Configuration screen; I tracked this down to
      hudson.util.FormFieldValidator line 368, where the system attempts to retrieve
      the PATH environment variable. Unfortunately this is case sensitive, and many
      Windows installations store this variable under the value Path - so it returns
      null, resulting in the NPE.

          [JENKINS-1115] NullPointerException in Configuration Screen

          mahoney266 created issue -

          Starting 1.162, EnvVars.masterEnvVars handles case insensitive look up
          correctly, so this should no longer be an issue. I'm assuming that you've been
          using an older version of Hudson.

          That said, technically speaking it's possible that PATH/Path is not set at all,
          regardless of upper/lower convention, so I added null check too. This change
          will be in 1.165.

          Kohsuke Kawaguchi added a comment - Starting 1.162, EnvVars.masterEnvVars handles case insensitive look up correctly, so this should no longer be an issue. I'm assuming that you've been using an older version of Hudson. That said, technically speaking it's possible that PATH/Path is not set at all, regardless of upper/lower convention, so I added null check too. This change will be in 1.165.
          Kohsuke Kawaguchi made changes -
          Resolution New: Fixed [ 1 ]
          Status Original: Open [ 1 ] New: Resolved [ 5 ]

          mahoney266 added a comment -

          Odd; the only version I have ever downloaded is 1.164, and renaming my Path
          variable (which definitely existed) to PATH fixed it. Never mind.

          mahoney266 added a comment - Odd; the only version I have ever downloaded is 1.164, and renaming my Path variable (which definitely existed) to PATH fixed it. Never mind.

          mahoney266 added a comment -

          Just wrote a quick test for it on my system, using hudson.EnvVars from
          hudson-1.164-src.zip. The following code fails at the second assert:

          assert EnvVars.masterEnvVars.get("Path").length() > 0;
          assert EnvVars.masterEnvVars.get("PATH") != null;

          The reason is that the static initialisation of masterEnvVars occurs before the
          static initialisation of CASE_INSENSITIVE_COMPARATOR, so that is null.

          mahoney266 added a comment - Just wrote a quick test for it on my system, using hudson.EnvVars from hudson-1.164-src.zip. The following code fails at the second assert: assert EnvVars.masterEnvVars.get("Path").length() > 0; assert EnvVars.masterEnvVars.get("PATH") != null; The reason is that the static initialisation of masterEnvVars occurs before the static initialisation of CASE_INSENSITIVE_COMPARATOR, so that is null.

          mahoney266 added a comment -

          Sorry, forgot to reopen.

          mahoney266 added a comment - Sorry, forgot to reopen.
          mahoney266 made changes -
          Resolution Original: Fixed [ 1 ]
          Status Original: Resolved [ 5 ] New: Reopened [ 4 ]

          mahoney266 added a comment -

          Created an attachment (id=153)
          Unit Test Proving Problem

          mahoney266 added a comment - Created an attachment (id=153) Unit Test Proving Problem

          mahoney266 added a comment -

          Created an attachment (id=154)
          Patch that fixes issue

          mahoney266 added a comment - Created an attachment (id=154) Patch that fixes issue

          mahoney266 added a comment -

          Thought I'd do it properly and provide a test and patch... mocking static calls
          on java.lang classes is a pig! If you can be bothered to make the unit test
          work, you need jmockit (https://jmockit.dev.java.net/) and you must run your
          test with the following VM arguments:

          -javaagent:<full_path_to>/jmockit.jar
          -Xbootclasspath/a:"<full_path_to_EnvVars_class>:<full_path_to_EnvVarsTest_class>:<full_path_to>/junit.jar:<full_path_to>/jmockit.jar"

          Just to make it more fun, the path and classpath separators have to be system
          correct. On my machine it looks like this:

          -javaagent:c:\jmockit.jar -Xbootclasspath/a:"c:\Eclipse
          Workspaces\hudson\hudson-core\target\classes;c:\Eclipse
          Workspaces\hudson\hudson-core\target\test-classes;c:\Program
          Files\eclipse\plugins\org.junit_3.8.2.v200711021030\junit.jar;c:\jmockit.jar"

          mahoney266 added a comment - Thought I'd do it properly and provide a test and patch... mocking static calls on java.lang classes is a pig! If you can be bothered to make the unit test work, you need jmockit ( https://jmockit.dev.java.net/ ) and you must run your test with the following VM arguments: -javaagent:<full_path_to>/jmockit.jar -Xbootclasspath/a:"<full_path_to_EnvVars_class>:<full_path_to_EnvVarsTest_class>:<full_path_to>/junit.jar:<full_path_to>/jmockit.jar" Just to make it more fun, the path and classpath separators have to be system correct. On my machine it looks like this: -javaagent:c:\jmockit.jar -Xbootclasspath/a:"c:\Eclipse Workspaces\hudson\hudson-core\target\classes;c:\Eclipse Workspaces\hudson\hudson-core\target\test-classes;c:\Program Files\eclipse\plugins\org.junit_3.8.2.v200711021030\junit.jar;c:\jmockit.jar"

            Unassigned Unassigned
            mahoney266 mahoney266
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved: