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

PatternSyntaxException in Windows when updating project files

    XMLWordPrintable

Details

    Description

      After adding a test project to my repository, I started getting the below error during the build when updating android project files.

      java.util.regex.PatternSyntaxException: Unexpected internal error near index 1
      \
      ^
      at java.util.regex.Pattern.error(Unknown Source)
      at java.util.regex.Pattern.compile(Unknown Source)
      at java.util.regex.Pattern.<init>(Unknown Source)
      at java.util.regex.Pattern.compile(Unknown Source)
      at java.lang.String.split(Unknown Source)
      at java.lang.String.split(Unknown Source)
      at hudson.plugins.android_emulator.util.Utils.getRelativePath(Utils.java:616)
      at hudson.plugins.android_emulator.util.Utils.getRelativePathDistance(Utils.java:665)
      at hudson.plugins.android_emulator.builder.UpdateProjectBuilder.perform(UpdateProjectBuilder.java:130)
      at hudson.tasks.BuildStepMonitor$1.perform(BuildStepMonitor.java:19)
      at hudson.model.AbstractBuild$AbstractBuildExecution.perform(AbstractBuild.java:804)
      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:586)
      at hudson.model.Run.execute(Run.java:1593)
      at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:46)
      at hudson.model.ResourceController.execute(ResourceController.java:88)
      at hudson.model.Executor.run(Executor.java:247)

      I tracked down the error which appears to be a misuse of the String.split function in plugins/android_emulator/util/Utils.java:616.

      // Target directory is somewhere above our directory
      String[] fromParts = fromPath.substring(1).split(File.separator);
      final int fromLength = fromParts.length;
      String[] toParts = toPath.substring(1).split(File.separator);
      final int toLength = toParts.length;

      File.separator is a string but String.split is expecting a regex. On windows, File.separator is an invalid regex.

      Attachments

        Activity

          aitorthered Aitor Mendaza added a comment -

          I have added some code to fix the bug. I have send a pull request to be integrated in the main branch:
          https://github.com/jenkinsci/android-emulator-plugin/pull/26

          aitorthered Aitor Mendaza added a comment - I have added some code to fix the bug. I have send a pull request to be integrated in the main branch: https://github.com/jenkinsci/android-emulator-plugin/pull/26

          Code changed in jenkins
          User: Aitor Mendaza-Ormaza
          Path:
          src/main/java/hudson/plugins/android_emulator/util/Utils.java
          http://jenkins-ci.org/commit/android-emulator-plugin/378acf0718d7c3086dbbbac6cfb1f0fe5ca9022e
          Log:
          [FIXED JENKINS-18970] Escape File.separator when used in a regex.

          scm_issue_link SCM/JIRA link daemon added a comment - Code changed in jenkins User: Aitor Mendaza-Ormaza Path: src/main/java/hudson/plugins/android_emulator/util/Utils.java http://jenkins-ci.org/commit/android-emulator-plugin/378acf0718d7c3086dbbbac6cfb1f0fe5ca9022e Log: [FIXED JENKINS-18970] Escape File.separator when used in a regex.

          Version 2.11 of the plugin has been released, which fixes this issue.

          orrc Christopher Orr added a comment - Version 2.11 of the plugin has been released, which fixes this issue.

          People

            aitorthered Aitor Mendaza
            ryanr23 Ryan Reading
            Votes:
            1 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: