Skip to content

Commit

Permalink
Ignore method invocation arguments that are not string J.Literals
Browse files Browse the repository at this point in the history
Fixes: #4275
  • Loading branch information
Jente Sondervorst committed Jun 20, 2024
1 parent 22ac272 commit ba6db7a
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -435,6 +435,9 @@ private J.MethodInvocation updateDependency(J.MethodInvocation method, Execution
}
} else if (arg instanceof J.Literal) {
J.Literal literal = (J.Literal) arg;
if (literal.getType() != JavaType.Primitive.String) {
return arg;
}
String gav = (String) literal.getValue();
if (gav == null) {
getCursor().putMessage(UPDATE_VERSION_ERROR_KEY, new IllegalStateException("Unable to update version"));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -882,4 +882,29 @@ void unknownConfiguration() {
)
);
}

@Test
@Issue("https://github.com/openrewrite/rewrite/issues/4275")
void noActionForNonStringLiterals() {
rewriteRun(
buildGradle(
"""
plugins {
id 'java'
}
repositories {
mavenCentral()
}
dependencies {
implementation(gradleApi())
jar {
enabled(true)
}
}
"""
)
);
}
}

0 comments on commit ba6db7a

Please sign in to comment.