From 92e33ac15ca1ab9a2ff3f337655b9e4ca8056cb6 Mon Sep 17 00:00:00 2001 From: Guillaume GERBAUD Date: Mon, 25 Nov 2024 15:05:42 +0100 Subject: [PATCH] Fix IndexOutOfBoundsException in EqualsAvoidsNull recipe fix #393 --- .../org/openrewrite/staticanalysis/EqualsAvoidsNullVisitor.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main/java/org/openrewrite/staticanalysis/EqualsAvoidsNullVisitor.java b/src/main/java/org/openrewrite/staticanalysis/EqualsAvoidsNullVisitor.java index 8ddc19a33..14864c924 100644 --- a/src/main/java/org/openrewrite/staticanalysis/EqualsAvoidsNullVisitor.java +++ b/src/main/java/org/openrewrite/staticanalysis/EqualsAvoidsNullVisitor.java @@ -59,6 +59,7 @@ public J visitMethodInvocation(J.MethodInvocation method, P p) { J.MethodInvocation m = (J.MethodInvocation) super.visitMethodInvocation(method, p); if (m.getSelect() != null && !(m.getSelect() instanceof J.Literal) && + !m.getArguments().isEmpty() && m.getArguments().get(0) instanceof J.Literal && isStringComparisonMethod(m)) { return literalsFirstInComparisonsBinaryCheck(m, getCursor().getParentTreeCursor().getValue());