• Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Minor Minor
    • clover-plugin
    • None
    • Linux

      Running Jenkins 1.505 on CentOS 6.2 Linux x86_64 under apache-tomcat-7.0.29. Clover plug-in version 4.0.6. I have the CLOVER license string set in the global Jenkins config.

      My build job is free-style, and I have an build step "invoke Ant" using Ant 1.8.4. I have Clover enabled in the Build Environment section checked as follows:

      [ * ] Automatically record and report Code Coverage using Clover. Currently for Ant builds only.
      Generate an historical report [ * ]
      Generate a json report [ * ]

      I get this error when I run the build job after SCM update and before the Ant build step:

      ...
      FATAL: Index: 2, Size: 2
      java.lang.IndexOutOfBoundsException: Index: 2, Size: 2
      at java.util.ArrayList.RangeCheck(ArrayList.java:547)
      at java.util.ArrayList.get(ArrayList.java:322)
      at hudson.plugins.clover.CloverBuildWrapper$CloverDecoratingLauncher.decorateArgs(CloverBuildWrapper.java:188)
      at hudson.plugins.clover.CloverBuildWrapper$CloverDecoratingLauncher.launch(CloverBuildWrapper.java:163)
      at hudson.Launcher$ProcStarter.start(Launcher.java:353)
      at hudson.Launcher$ProcStarter.join(Launcher.java:360)
      at hudson.tasks.CommandInterpreter.perform(CommandInterpreter.java:91)
      at hudson.tasks.CommandInterpreter.perform(CommandInterpreter.java:60)
      at hudson.tasks.BuildStepMonitor$1.perform(BuildStepMonitor.java:19)
      at hudson.model.AbstractBuild$AbstractBuildExecution.perform(AbstractBuild.java:814)
      at hudson.model.Build$BuildExecution.build(Build.java:199)
      at hudson.model.Build$BuildExecution.doRun(Build.java:160)
      at hudson.model.AbstractBuild$AbstractBuildExecution.run(AbstractBuild.java:593)
      at hudson.model.Run.execute(Run.java:1567)
      at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:46)
      at hudson.model.ResourceController.execute(ResourceController.java:88)
      at hudson.model.Executor.run(Executor.java:237)

      Thanks for advice/help on this.
      -Greg

          [JENKINS-18953] Clover java.lang.IndexOutOfBoundsException

          Jesse Glick added a comment -

          CloverDecoratingLauncher makes no attempt to check whether the command it is decorating is even an Ant command at all! For example:

          […] $ cleartool endview -server …
          
          FATAL: Index: 2, Size: 2
          java.lang.IndexOutOfBoundsException: Index: 2, Size: 2
          	at java.util.ArrayList.rangeCheck(ArrayList.java:604)
          	at java.util.ArrayList.get(ArrayList.java:382)
          	at hudson.plugins.clover.CloverBuildWrapper$CloverDecoratingLauncher.decorateArgs(CloverBuildWrapper.java:224)
          	at hudson.plugins.clover.CloverBuildWrapper$CloverDecoratingLauncher.launch(CloverBuildWrapper.java:199)
          	at hudson.Launcher$ProcStarter.start(Launcher.java:353)
          	at hudson.plugins.clearcase.HudsonClearToolLauncher.getLaunchedProc(HudsonClearToolLauncher.java:71)
          	at hudson.plugins.clearcase.HudsonClearToolLauncher.run(HudsonClearToolLauncher.java:143)
          	at hudson.plugins.clearcase.ClearToolExec.version(ClearToolExec.java:865)
          	at hudson.plugins.clearcase.ClearToolExec.doesSetcsSupportOverride(ClearToolExec.java:181)
          	at hudson.plugins.clearcase.ClearToolExec.setcs(ClearToolExec.java:1079)
          	at hudson.plugins.clearcase.ClearToolExec.setcs2(ClearToolExec.java:770)
          	at hudson.plugins.clearcase.action.BaseSnapshotCheckoutAction.checkout(BaseSnapshotCheckoutAction.java:80)
          	at hudson.plugins.clearcase.AbstractClearCaseScm.checkout(AbstractClearCaseScm.java:383)
          	at hudson.model.AbstractProject.checkout(AbstractProject.java:1411)
          

          Jesse Glick added a comment - CloverDecoratingLauncher makes no attempt to check whether the command it is decorating is even an Ant command at all! For example: […] $ cleartool endview -server … FATAL: Index: 2, Size: 2 java.lang.IndexOutOfBoundsException: Index: 2, Size: 2 at java.util.ArrayList.rangeCheck(ArrayList.java:604) at java.util.ArrayList.get(ArrayList.java:382) at hudson.plugins.clover.CloverBuildWrapper$CloverDecoratingLauncher.decorateArgs(CloverBuildWrapper.java:224) at hudson.plugins.clover.CloverBuildWrapper$CloverDecoratingLauncher.launch(CloverBuildWrapper.java:199) at hudson.Launcher$ProcStarter.start(Launcher.java:353) at hudson.plugins.clearcase.HudsonClearToolLauncher.getLaunchedProc(HudsonClearToolLauncher.java:71) at hudson.plugins.clearcase.HudsonClearToolLauncher.run(HudsonClearToolLauncher.java:143) at hudson.plugins.clearcase.ClearToolExec.version(ClearToolExec.java:865) at hudson.plugins.clearcase.ClearToolExec.doesSetcsSupportOverride(ClearToolExec.java:181) at hudson.plugins.clearcase.ClearToolExec.setcs(ClearToolExec.java:1079) at hudson.plugins.clearcase.ClearToolExec.setcs2(ClearToolExec.java:770) at hudson.plugins.clearcase.action.BaseSnapshotCheckoutAction.checkout(BaseSnapshotCheckoutAction.java:80) at hudson.plugins.clearcase.AbstractClearCaseScm.checkout(AbstractClearCaseScm.java:383) at hudson.model.AbstractProject.checkout(AbstractProject.java:1411)

          Hi Jesse,

          I looked at the source code and the issue is as follows.

           

          On Linux an Ant command looks like this:

          ant clean test

          and on Windows the same Ant command looks like this:

          "cmd.exe", "/C", "\"ant.bat clean test && exit %%ERRORLEVEL%%\""

           

          The code throwing this exception has the following check to recognize if there is "cmd.exe /C":

          if (!cmds.isEmpty() && cmds.size() >= numPreSystemCmds && !cmds.get(0).endsWith("ant")) {

          If yes, it tries to cut first two arguments:

          String argString = cmds.get(numPreSystemCmds);

           

           

          Therefore, if your command has more than two arguments and the first one does not end with "ant", it will assume that it's a windows-style. 

          I guess that on your Linux you used a non-standard name of Ant executable (e.g. a symlink like "/usr/bin/ant-1.9.4" or some shell script e.g. "/usr/bin/my-ant-wrapper.sh") and thus it recognized it incorrectly. 

          Am I right? If yes, then is is rather an improvement, not a bug.

          Cheers
          Marek

          Marek Parfianowicz added a comment - Hi Jesse, I looked at the source code and the issue is as follows.   On Linux an Ant command looks like this: ant clean test and on Windows the same Ant command looks like this: "cmd.exe", "/C", "\"ant.bat clean test && exit %%ERRORLEVEL%%\""   The code throwing this exception has the following check to recognize if there is "cmd.exe /C": if (!cmds.isEmpty() && cmds.size() >= numPreSystemCmds && !cmds.get(0).endsWith("ant")) { If yes, it tries to cut first two arguments: String argString = cmds.get(numPreSystemCmds);     Therefore, if your command has more than two arguments and the first one does not end with "ant", it will assume that it's a windows-style.  I guess that on your Linux you used a non-standard name of Ant executable (e.g. a symlink like "/usr/bin/ant-1.9.4" or some shell script e.g. "/usr/bin/my-ant-wrapper.sh") and thus it recognized it incorrectly.  Am I right? If yes, then is is rather an improvement, not a bug. Cheers Marek

          Workaround:

          Ensure that path to your Ant executable ends with "ant" on Linux. 

          Marek Parfianowicz added a comment - Workaround: Ensure that path to your Ant executable ends with "ant" on Linux. 

          I completely redesigned how command decoration works in this commit. Change has been delivered in clover-plugin 4.9.0. I consider this issue closed.

          Marek Parfianowicz added a comment - I completely redesigned how command decoration works in this commit . Change has been delivered in clover-plugin 4.9.0. I consider this issue closed.

            Unassigned Unassigned
            killmayne Greg Baysden
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated:
              Resolved: