openrewrite / openrewrite/rewrite

Index out of bound in extensionless file

Open
#3,737 5 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug groovy
Dominant language
Java
Stars
3.7k
Forks
571
Avg merge
13h 12m
Merged PRs (30d)
261

Description

What version of OpenRewrite are you using?

I am using Maven plugin v5.14.0

How are you running OpenRewrite?

I am using the Maven plugin, and my project is a single module project.

 mvn -U -X org.openrewrite.maven:rewrite-maven-plugin:run -D rewrite.recipeArtifactCoordinates=org.openrewrite.recipe:rewrite-migrate-java:RELEASE -D rewrite.activeRecipes=
org.openrewrite.java.migrate.UpgradeToJava21

What is the full stack trace of any errors you encountered?

Error while visiting scripts\jenkins-promote\dev-tst\Jenkinsfile_promoteToTST: java.lang.IndexOutOfBoundsException: Index 0 out of bounds for length 0
  java.base/jdk.internal.util.Preconditions.outOfBounds(Preconditions.java:100)
  java.base/jdk.internal.util.Preconditions.outOfBoundsCheckIndex(Preconditions.java:106)
  java.base/jdk.internal.util.Preconditions.checkIndex(Preconditions.java:302)
  java.base/java.util.Objects.checkIndex(Objects.java:385)
  java.base/java.util.ArrayList.get(ArrayList.java:427)
  org.openrewrite.java.JavaTemplate$Matcher.parameter(JavaTemplate.java:103)
  org.openrewrite.java.migrate.net.URLConstructorsToURIRecipes$URLSingleArgumentConstructorRecipe$1.visitExpression(URLConstructorsToURIRecipes.java:68)
  org.openrewrite.java.migrate.net.URLConstructorsToURIRecipes$URLSingleArgumentConstructorRecipe$1.visitExpression(URLConstructorsToURIRecipes.java:57)

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the Maven command against the extensionless Jenkinsfile path shown in the report. Read JavaTemplate.Matcher.parameter and URLConstructorsToURIRecipes.URLSingleArgumentConstructorRecipe around the reported lines to determine why an empty parameter list is indexed. Done means the recipe no longer raises IndexOutOfBoundsException for this input.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
tooling
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.