Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

A java.lang.StringIndexOutOfBoundsException was thrown when YAML files contains string that ends with . #4817

Open
EricleeCrystal opened this issue Dec 26, 2024 · 0 comments
Labels
bug Something isn't working

Comments

@EricleeCrystal
Copy link

EricleeCrystal commented Dec 26, 2024

What version of OpenRewrite are you using?

I am using

  • OpenRewrite v2.23.2 (org.openrewrite.recipe:rewrite-recipe-bom:2.23.2)
  • Maven plugin v5.47.0
  • Maven 3.9.8

How are you running OpenRewrite?

I am using the maven plugin by below command, and my project is a multiple module project.

mvn -B org.openrewrite.maven:rewrite-maven-plugin:5.47.0:runNoFork \
-Drewrite.activeRecipes=org.openrewrite.java.jackson.CodehausClassesToFasterXML \
-Drewrite.recipeArtifactCoordinates=org.openrewrite.recipe:rewrite-spring:5.25.0,org.openrewrite.recipe:rewrite-apache:1.10.0,org.openrewrite.recipe:rewrite-jackson:0.11.0 \
-Dproject.prerequisites.maven=3.0
-f ./pom.xml

What is the smallest, simplest way to reproduce the problem?

  1. Create a simple spring boot project from the https://start.spring.io/
  2. Change the parent version to 2.7.18, rename the application.properties to application.yml, and add below configuration to the application.yml.
ignorePattern: ['a.b.']
  1. Execute below command
mvn -B org.openrewrite.maven:rewrite-maven-plugin:5.47.0:runNoFork \
-Drewrite.activeRecipes=org.openrewrite.java.jackson.CodehausClassesToFasterXML \
-Drewrite.recipeArtifactCoordinates=org.openrewrite.recipe:rewrite-spring:5.25.0,org.openrewrite.recipe:rewrite-apache:1.10.0,org.openrewrite.recipe:rewrite-jackson:0.11.0 \
-Dproject.prerequisites.maven=3.0
-f ./pom.xml

What did you expect to see?

There is no exception thrown.

What did you see instead?

Below exception thrown.

[ERROR] Failed to execute goal org.openrewrite.maven:rewrite-maven-plugin:5.47.0:runNoFork (default-cli) on project demo: Execution default-cli of goal org.openrewrite.maven:rewrite-maven-plugin:5.47.0:runNoFork failed: Error while visiting src/main/resources/application.yml: java.lang.StringIndexOutOfBoundsException: String index out of range: 4

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

[ERROR] Failed to execute goal org.openrewrite.maven:rewrite-maven-plugin:5.47.0:runNoFork (default-cli) on project demo: Execution default-cli of goal org.openrewrite.maven:rewrite-maven-plugin:5.47.0:runNoFork failed: Error while visiting src/main/resources/application.yml: java.lang.StringIndexOutOfBoundsException: String index out of range: 4
[ERROR]   java.base/java.lang.StringLatin1.charAt(StringLatin1.java:48)
[ERROR]   java.base/java.lang.String.charAt(String.java:1513)
[ERROR]   org.openrewrite.yaml.trait.YamlReference$Matcher.determineKind(YamlReference.java:81)
[ERROR]   org.openrewrite.yaml.trait.YamlReference$Matcher.test(YamlReference.java:75)
[ERROR]   org.openrewrite.yaml.trait.YamlReference$Matcher.test(YamlReference.java:65)
[ERROR]   org.openrewrite.trait.SimpleTraitMatcher$1.preVisit(SimpleTraitMatcher.java:77)
[ERROR]   org.openrewrite.trait.SimpleTraitMatcher_1_YamlVisitor.preVisit(SimpleTraitMatcher_1_YamlVisitor.zig:81)
[ERROR]   org.openrewrite.TreeVisitor.visit(TreeVisitor.java:247)
[ERROR]   org.openrewrite.TreeVisitor.visitAndCast(TreeVisitor.java:320)
[ERROR]   org.openrewrite.yaml.YamlVisitor.visitSequenceEntry(YamlVisitor.java:105)
[ERROR]   org.openrewrite.yaml.tree.Yaml$Sequence$Entry.acceptYaml(Yaml.java:438)
[ERROR]   org.openrewrite.yaml.tree.Yaml.accept(Yaml.java:43)
[ERROR]   org.openrewrite.TreeVisitor.visit(TreeVisitor.java:250)
[ERROR]   org.openrewrite.TreeVisitor.visitAndCast(TreeVisitor.java:320)
[ERROR]   org.openrewrite.yaml.YamlVisitor.lambda$visitSequence$2(YamlVisitor.java:100)
[ERROR]   org.openrewrite.internal.ListUtils.map(ListUtils.java:243)
[ERROR]   ...
[ERROR] -> [Help 1]
@EricleeCrystal EricleeCrystal added the bug Something isn't working label Dec 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
Status: No status
Development

No branches or pull requests

1 participant