jenkins-infra / plugin-modernizer-tool

MIT License
15 stars 23 forks source link

`java.lang.IndexOutOfBoundsException: Index -1 out of bounds for length 0` #714

Closed gounthar closed 3 weeks ago

gounthar commented 3 weeks ago

Plugin Modernizer version

plugin modernizer 999999-SNAPSHOT (2025-01-25T14:24:40Z)

What Operating System are you using

Debian / WSL3

Reproduction steps

java -jar plugin-modernizer-cli/target/jenkins-plugin-modernizer-999999-SNAPSHOT.jar run --plugins valid-network --recipe UpgradeToRecommendCoreVersion

Expected Results

No error.

Results

2025-01-25T14:36:09.723Z [INFO] [Thread=StreamPumper-systemOut] - i.j.t.p.core.impl.MavenInvoker # [INFO] Project is using Jenkins bom at version 3
2025-01-25T14:36:09.873Z [INFO] [Thread=StreamPumper-systemOut] - i.j.t.p.core.impl.MavenInvoker # [ERROR] The recipe produced an error. Please report this to the recipe author.
2025-01-25T14:36:09.878Z [INFO] [Thread=StreamPumper-systemOut] - i.j.t.p.core.impl.MavenInvoker # [INFO] ------------------------------------------------------------------------
2025-01-25T14:36:09.880Z [INFO] [Thread=StreamPumper-systemOut] - i.j.t.p.core.impl.MavenInvoker # [INFO] BUILD FAILURE
2025-01-25T14:36:09.881Z [INFO] [Thread=StreamPumper-systemOut] - i.j.t.p.core.impl.MavenInvoker # [INFO] ------------------------------------------------------------------------
2025-01-25T14:36:09.882Z [INFO] [Thread=StreamPumper-systemOut] - i.j.t.p.core.impl.MavenInvoker # [INFO] Total time:  22.180 s
2025-01-25T14:36:09.883Z [INFO] [Thread=StreamPumper-systemOut] - i.j.t.p.core.impl.MavenInvoker # [INFO] Finished at: 2025-01-25T15:36:09+01:00
2025-01-25T14:36:09.884Z [INFO] [Thread=StreamPumper-systemOut] - i.j.t.p.core.impl.MavenInvoker # [INFO] ------------------------------------------------------------------------
2025-01-25T14:36:09.885Z [INFO] [Thread=StreamPumper-systemOut] - i.j.t.p.core.impl.MavenInvoker # [ERROR] Failed to execute goal org.openrewrite.maven:rewrite-maven-plugin:6.0.5:run (default-cli) on project valid-network: Execution default-cli of goal org.openrewrite.maven:rewrite-maven-plugin:6.0.5:run failed: Error while visiting pom.xml: java.lang.IndexOutOfBoundsException: Index -1 out of bounds for length 0
2025-01-25T14:36:09.886Z [INFO] [Thread=StreamPumper-systemOut] - i.j.t.p.core.impl.MavenInvoker # [ERROR]   java.base/jdk.internal.util.Preconditions.outOfBounds(Preconditions.java:64)
2025-01-25T14:36:09.887Z [INFO] [Thread=StreamPumper-systemOut] - i.j.t.p.core.impl.MavenInvoker # [ERROR]   java.base/jdk.internal.util.Preconditions.outOfBoundsCheckIndex(Preconditions.java:70)
2025-01-25T14:36:09.887Z [INFO] [Thread=StreamPumper-systemOut] - i.j.t.p.core.impl.MavenInvoker # [ERROR]   java.base/jdk.internal.util.Preconditions.checkIndex(Preconditions.java:266)
2025-01-25T14:36:09.888Z [INFO] [Thread=StreamPumper-systemOut] - i.j.t.p.core.impl.MavenInvoker # [ERROR]   java.base/java.util.Objects.checkIndex(Objects.java:361)
2025-01-25T14:36:09.889Z [INFO] [Thread=StreamPumper-systemOut] - i.j.t.p.core.impl.MavenInvoker # [ERROR]   java.base/java.util.ArrayList.get(ArrayList.java:427)
2025-01-25T14:36:09.890Z [INFO] [Thread=StreamPumper-systemOut] - i.j.t.p.core.impl.MavenInvoker # [ERROR]   io.jenkins.tools.pluginmodernizer.core.visitors.UpdateBomVersionVisitor.getLatestBomVersion(UpdateBomVersionVisitor.java:166)
2025-01-25T14:36:09.891Z [INFO] [Thread=StreamPumper-systemOut] - i.j.t.p.core.impl.MavenInvoker # [ERROR]   io.jenkins.tools.pluginmodernizer.core.visitors.UpdateBomVersionVisitor.getLatestBomVersion(UpdateBomVersionVisitor.java:109)
2025-01-25T14:36:09.892Z [INFO] [Thread=StreamPumper-systemOut] - i.j.t.p.core.impl.MavenInvoker # [ERROR]   io.jenkins.tools.pluginmodernizer.core.visitors.UpdateBomVersionVisitor.visitDocument(UpdateBomVersionVisitor.java:85)
2025-01-25T14:36:09.893Z [INFO] [Thread=StreamPumper-systemOut] - i.j.t.p.core.impl.MavenInvoker # [ERROR]   io.jenkins.tools.pluginmodernizer.core.visitors.UpdateBomVersionVisitor.visitDocument(UpdateBomVersionVisitor.java:25)
2025-01-25T14:36:09.894Z [INFO] [Thread=StreamPumper-systemOut] - i.j.t.p.core.impl.MavenInvoker # [ERROR]   org.openrewrite.xml.tree.Xml$Document.acceptXml(Xml.java:149)
2025-01-25T14:36:09.895Z [INFO] [Thread=StreamPumper-systemOut] - i.j.t.p.core.impl.MavenInvoker # [ERROR]   org.openrewrite.xml.tree.Xml.accept(Xml.java:53)
2025-01-25T14:36:09.896Z [INFO] [Thread=StreamPumper-systemOut] - i.j.t.p.core.impl.MavenInvoker # [ERROR]   org.openrewrite.TreeVisitor.visit(TreeVisitor.java:250)
2025-01-25T14:36:09.897Z [INFO] [Thread=StreamPumper-systemOut] - i.j.t.p.core.impl.MavenInvoker # [ERROR]   org.openrewrite.TreeVisitor.visit(TreeVisitor.java:157)
2025-01-25T14:36:09.898Z [INFO] [Thread=StreamPumper-systemOut] - i.j.t.p.core.impl.MavenInvoker # [ERROR]   org.openrewrite.Preconditions$Check.visit(Preconditions.java:175)
2025-01-25T14:36:09.899Z [INFO] [Thread=StreamPumper-systemOut] - i.j.t.p.core.impl.MavenInvoker # [ERROR]   org.openrewrite.Preconditions$Check.visit(Preconditions.java:145)
2025-01-25T14:36:09.899Z [INFO] [Thread=StreamPumper-systemOut] - i.j.t.p.core.impl.MavenInvoker # [ERROR]   org.openrewrite.scheduling.RecipeRunCycle.lambda$editSources$6(RecipeRunCycle.java:186)
2025-01-25T14:36:09.900Z [INFO] [Thread=StreamPumper-systemOut] - i.j.t.p.core.impl.MavenInvoker # [ERROR]   ...
2025-01-25T14:36:09.901Z [INFO] [Thread=StreamPumper-systemOut] - i.j.t.p.core.impl.MavenInvoker # [ERROR] -> [Help 1]
2025-01-25T14:36:09.902Z [INFO] [Thread=StreamPumper-systemOut] - i.j.t.p.core.impl.MavenInvoker # [ERROR]
2025-01-25T14:36:09.904Z [INFO] [Thread=StreamPumper-systemOut] - i.j.t.p.core.impl.MavenInvoker # [ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
2025-01-25T14:36:09.905Z [INFO] [Thread=StreamPumper-systemOut] - i.j.t.p.core.impl.MavenInvoker # [ERROR] Re-run Maven using the -X switch to enable full debug logging.
2025-01-25T14:36:09.906Z [INFO] [Thread=StreamPumper-systemOut] - i.j.t.p.core.impl.MavenInvoker # [ERROR]
2025-01-25T14:36:09.907Z [INFO] [Thread=StreamPumper-systemOut] - i.j.t.p.core.impl.MavenInvoker # [ERROR] For more information about the errors and possible solutions, please read the following articles:
2025-01-25T14:36:09.909Z [INFO] [Thread=StreamPumper-systemOut] - i.j.t.p.core.impl.MavenInvoker # [ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/PluginExecutionException
2025-01-25T14:36:09.959Z [ERROR] [Thread=main] - i.j.t.p.core.impl.MavenInvoker # Build fail with code: 1
jonesbusy commented 3 weeks ago

Interesting

            <dependency>
                <!-- Pick up common dependencies for 2.164.x: https://github.com/jenkinsci/bom#usage -->
                <groupId>io.jenkins.tools.bom</groupId>
                <artifactId>bom-2.164.x</artifactId>
                <version>3</version>
                <scope>import</scope>
                <type>pom</type>
            </dependency>

Should be easy to fix by implementing a test that validate a pom with such bom

gounthar commented 3 weeks ago

Thanks a bunch, @jonesbusy , this worked and produced: https://github.com/jenkinsci/valid-network-plugin/pull/9 .