From cf38d6453593692f9e50afabc608be9226ffab4c Mon Sep 17 00:00:00 2001 From: Jonathan Schneider Date: Fri, 1 Mar 2024 06:25:55 -0500 Subject: [PATCH] Guard against ClassCastException in UpgradeTransitiveDependencyVersion --- .../gradle/UpgradeTransitiveDependencyVersion.java | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/rewrite-gradle/src/main/java/org/openrewrite/gradle/UpgradeTransitiveDependencyVersion.java b/rewrite-gradle/src/main/java/org/openrewrite/gradle/UpgradeTransitiveDependencyVersion.java index 122e820cc33..40cbbe1882c 100644 --- a/rewrite-gradle/src/main/java/org/openrewrite/gradle/UpgradeTransitiveDependencyVersion.java +++ b/rewrite-gradle/src/main/java/org/openrewrite/gradle/UpgradeTransitiveDependencyVersion.java @@ -263,6 +263,9 @@ public J.MethodInvocation visitMethodInvocation(J.MethodInvocation method, Execu .withMarkers(Markers.EMPTY); return autoFormat(m.withArguments(ListUtils.mapFirst(m.getArguments(), arg -> { + if(!(arg instanceof J.Lambda)) { + return arg; + } J.Lambda dependencies = (J.Lambda) arg; if (!(dependencies.getBody() instanceof J.Block)) { return m; @@ -360,6 +363,9 @@ public J.MethodInvocation visitMethodInvocation(J.MethodInvocation method, Execu .withMarkers(Markers.EMPTY); m = autoFormat(m.withArguments(ListUtils.mapFirst(m.getArguments(), arg -> { + if(!(arg instanceof J.Lambda)) { + return arg; + } J.Lambda dependencies = (J.Lambda) arg; if (!(dependencies.getBody() instanceof J.Block)) { return arg;