From 9965bbf5f26d3492100086d38cb9647071833108 Mon Sep 17 00:00:00 2001 From: Kun Li Date: Mon, 20 Nov 2023 09:41:00 -0800 Subject: [PATCH] Add safe null check for visiting J.TypeParameter's modifiers --- .../src/main/java/org/openrewrite/java/JavaVisitor.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/rewrite-java/src/main/java/org/openrewrite/java/JavaVisitor.java b/rewrite-java/src/main/java/org/openrewrite/java/JavaVisitor.java index 8a5ad94e4cc..b0013e9be57 100644 --- a/rewrite-java/src/main/java/org/openrewrite/java/JavaVisitor.java +++ b/rewrite-java/src/main/java/org/openrewrite/java/JavaVisitor.java @@ -1191,7 +1191,11 @@ public J visitTypeParameter(J.TypeParameter typeParam, P p) { t = t.withPrefix(visitSpace(t.getPrefix(), Space.Location.TYPE_PARAMETERS_PREFIX, p)); t = t.withMarkers(visitMarkers(t.getMarkers(), p)); t = t.withAnnotations(ListUtils.map(t.getAnnotations(), a -> visitAndCast(a, p))); - t = t.withModifiers(ListUtils.map(t.getModifiers(), m -> visitAndCast(m, p))); + + if (t.getModifiers() != null && !t.getModifiers().isEmpty()) { + t = t.withModifiers(ListUtils.map(t.getModifiers(), m -> visitAndCast(m, p))); + } + t = t.withName(visitAndCast(t.getName(), p)); if (t.getName() instanceof NameTree) { t = t.withName((Expression) visitTypeName((NameTree) t.getName(), p));