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

git-client-plugin: StringIndexOutOfBoundsException when parsing branches

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Minor Minor
    • git-client-plugin
    • None

      we ran into this:

      > git checkout -f a6ecfa813a4c9a5699df4ec39cfdd596852b8d71 # timeout=10
      > git branch -a -v --no-abbrev # timeout=10
      FATAL: String index out of range: -1
      java.lang.StringIndexOutOfBoundsException: String index out of range: -1
      at java.lang.String.substring(String.java:1931)
      at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.parseBranches(CliGitAPIImpl.java:1825)
      at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.getBranches(CliGitAPIImpl.java:1847)
      at hudson.plugins.git.GitAPI.getBranches(GitAPI.java:195)
      at org.jenkinsci.plugins.gitclient.CliGitAPIImpl$9.execute(CliGitAPIImpl.java:1969)
      at org.jenkinsci.plugins.gitclient.RemoteGitImpl$CommandInvocationHandler$1.call(RemoteGitImpl.java:152)
      at org.jenkinsci.plugins.gitclient.RemoteGitImpl$CommandInvocationHandler$1.call(RemoteGitImpl.java:145)
      at hudson.remoting.UserRequest.perform(UserRequest.java:120)
      at hudson.remoting.UserRequest.perform(UserRequest.java:48)
      at hudson.remoting.Request$2.run(Request.java:332)
      at hudson.remoting.InterceptingExecutorService$1.call(InterceptingExecutorService.java:68)
      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)
      at ......remote call to jenkins-node-1(Native Method)
      at hudson.remoting.Channel.attachCallSiteStackTrace(Channel.java:1416)
      at hudson.remoting.UserResponse.retrieve(UserRequest.java:220)
      at hudson.remoting.Channel.call(Channel.java:781)
      at org.jenkinsci.plugins.gitclient.RemoteGitImpl$CommandInvocationHandler.execute(RemoteGitImpl.java:145)
      at sun.reflect.GeneratedMethodAccessor208.invoke(Unknown Source)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      at java.lang.reflect.Method.invoke(Method.java:606)
      at org.jenkinsci.plugins.gitclient.RemoteGitImpl$CommandInvocationHandler.invoke(RemoteGitImpl.java:131)
      at com.sun.proxy.$Proxy65.execute(Unknown Source)
      at hudson.plugins.git.GitSCM.checkout(GitSCM.java:1135)
      at hudson.scm.SCM.checkout(SCM.java:485)
      at hudson.model.AbstractProject.checkout(AbstractProject.java:1269)
      at hudson.model.AbstractBuild$AbstractBuildExecution.defaultCheckout(AbstractBuild.java:607)
      at jenkins.scm.SCMCheckoutStrategy.checkout(SCMCheckoutStrategy.java:86)
      at hudson.model.AbstractBuild$AbstractBuildExecution.run(AbstractBuild.java:529)
      at hudson.model.Run.execute(Run.java:1738)
      at hudson.maven.MavenModuleSetBuild.run(MavenModuleSetBuild.java:531)
      at hudson.model.ResourceController.execute(ResourceController.java:98)
      at hudson.model.Executor.run(Executor.java:410)

      -> turned out to be a DOS line ending in a commit message “...^M” - which leads to parsing an empty line here
      ====

      versions:
      jenkins-ci: Jenkins ver. 1.656
      Git client plugin 1.19.6
      Git plugin 2.4.4

          [JENKINS-34309] git-client-plugin: StringIndexOutOfBoundsException when parsing branches

          Frank Geusch added a comment - - edited

          i’m on it, matter-of-factly I'm also unable to provide an example currently - I’m guessing a certain older git version had this issue; some of my colleagues was inducing this a couple weeks ago, I will get into this on Monday;
          also, this is rather a minor issue, as it is easily mitigable by just tidying up the culprit message

          Frank Geusch added a comment - - edited i’m on it, matter-of-factly I'm also unable to provide an example currently - I’m guessing a certain older git version had this issue; some of my colleagues was inducing this a couple weeks ago, I will get into this on Monday; also, this is rather a minor issue, as it is easily mitigable by just tidying up the culprit message

          This bug is also triggered by this Gitlab bug:

          https://gitlab.com/gitlab-org/gitlab-ce/issues/14453

          The Gitlab bug has been fixed 4 months ago and is in the leatests releases, but since we hadn't updated yet, we were hit by it last week.

          Christopher Arndt added a comment - This bug is also triggered by this Gitlab bug: https://gitlab.com/gitlab-org/gitlab-ce/issues/14453 The Gitlab bug has been fixed 4 months ago and is in the leatests releases, but since we hadn't updated yet, we were hit by it last week.

          Mark Waite added a comment - - edited

          If you'd be willing to try a pre-release, pull request 213 has been built and can be downloaded from the pull request builder.

          It ran in my multi-platform test environment successfully, reporting no pareseBranches related StringIndexOutOfBoundsException messages in settings where I was previously seeing them.

          Mark Waite added a comment - - edited If you'd be willing to try a pre-release, pull request 213 has been built and can be downloaded from the pull request builder . It ran in my multi-platform test environment successfully, reporting no pareseBranches related StringIndexOutOfBoundsException messages in settings where I was previously seeing them.

          Thanks for the info. I will talk to our admins about trying your branch. I hope it will be merged soon.

          Christopher Arndt added a comment - Thanks for the info. I will talk to our admins about trying your branch. I hope it will be merged soon.

          James Murphy added a comment -

          Hi,

          We hit the same issue during one of our builds, wanted to add that we were able to downgrade the git client plugin back to 1.8.1 to bypass the issue.
          Not sure how to go back and search each commit that happened for a new line.... in our case the culprit commit is not the most recent, so we would need to go back and update ones that happened several commits ago... not sure how to do that yet....

          James Murphy added a comment - Hi, We hit the same issue during one of our builds, wanted to add that we were able to downgrade the git client plugin back to 1.8.1 to bypass the issue. Not sure how to go back and search each commit that happened for a new line.... in our case the culprit commit is not the most recent, so we would need to go back and update ones that happened several commits ago... not sure how to do that yet....

          Mark Waite added a comment -

          Git client plugin 1.18.1 is quite old. Is there a reason you went backwards that far rather than trying the pre-release mentioned earlier?

          Mark Waite added a comment - Git client plugin 1.18.1 is quite old. Is there a reason you went backwards that far rather than trying the pre-release mentioned earlier?

          James Murphy added a comment -

          Hi Mark,

          No special reason, it was the previously installed version, and I had known it was working then (plus the downgrade to previously installed version button was conveniently there).
          Also we were against a deadline, and choose to downgrade instead of going through all the commits searching for messages that had newlines, and that second link you posted to download the build from is no longer pointing to an existing artifact...

          James Murphy added a comment - Hi Mark, No special reason, it was the previously installed version, and I had known it was working then (plus the downgrade to previously installed version button was conveniently there). Also we were against a deadline, and choose to downgrade instead of going through all the commits searching for messages that had newlines, and that second link you posted to download the build from is no longer pointing to an existing artifact...

          James Murphy added a comment - - edited

          I downloaded and built the plugin from the master branch. After loading the pre-release plugin into Jenkins plugins, seems to be working fine. Thanks Mark.

          James Murphy added a comment - - edited I downloaded and built the plugin from the master branch. After loading the pre-release plugin into Jenkins plugins, seems to be working fine. Thanks Mark.

          Mark Waite added a comment -

          Fixed in git client plugin 1.19.7 released 15 Jul 2016

          Mark Waite added a comment - Fixed in git client plugin 1.19.7 released 15 Jul 2016

          Code changed in jenkins
          User: Mark Waite
          Path:
          src/main/java/org/jenkinsci/plugins/gitclient/CliGitAPIImpl.java
          src/test/java/org/jenkinsci/plugins/gitclient/CliGitAPIImplTest.java
          http://jenkins-ci.org/commit/git-client-plugin/85e6a0da7559a46442cdc2910461bf57bbc50ea9
          Log:
          Merge pull request #273 from bmleite/patch-1

          Protect against ArrayIndexOutOfBoundsException (related to JENKINS-34309)

          Compare: https://github.com/jenkinsci/git-client-plugin/compare/51ec170386bb...85e6a0da7559

          SCM/JIRA link daemon added a comment - Code changed in jenkins User: Mark Waite Path: src/main/java/org/jenkinsci/plugins/gitclient/CliGitAPIImpl.java src/test/java/org/jenkinsci/plugins/gitclient/CliGitAPIImplTest.java http://jenkins-ci.org/commit/git-client-plugin/85e6a0da7559a46442cdc2910461bf57bbc50ea9 Log: Merge pull request #273 from bmleite/patch-1 Protect against ArrayIndexOutOfBoundsException (related to JENKINS-34309 ) Compare: https://github.com/jenkinsci/git-client-plugin/compare/51ec170386bb...85e6a0da7559

            Unassigned Unassigned
            zerofudge Frank Geusch
            Votes:
            0 Vote for this issue
            Watchers:
            7 Start watching this issue

              Created:
              Updated:
              Resolved: