From ef5447add7dddc4518e2ef1578f8e89ad9c8a409 Mon Sep 17 00:00:00 2001 From: Looly Date: Sun, 2 Jun 2024 10:40:28 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8DAnnotationUtil=E5=8F=AF?= =?UTF-8?q?=E8=83=BD=E7=9A=84=E7=A9=BA=E6=8C=87=E9=92=88=E9=94=99=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CHANGELOG.md | 1 + .../core/annotation/CombinationAnnotationElement.java | 9 +++++++++ 2 files changed, 10 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index fdbc23004..b5186e512 100755 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,7 @@ * 【core 】 ListUtil增加move方法(issue#3603@Github) ### 🐞Bug修复 +* 【core 】 修复AnnotationUtil可能的空指针错误 ------------------------------------------------------------------------------------------------------------- # 5.8.28(2024-05-29) diff --git a/hutool-core/src/main/java/cn/hutool/core/annotation/CombinationAnnotationElement.java b/hutool-core/src/main/java/cn/hutool/core/annotation/CombinationAnnotationElement.java index bfe8b8598..c11ec9482 100755 --- a/hutool-core/src/main/java/cn/hutool/core/annotation/CombinationAnnotationElement.java +++ b/hutool-core/src/main/java/cn/hutool/core/annotation/CombinationAnnotationElement.java @@ -1,6 +1,7 @@ package cn.hutool.core.annotation; import cn.hutool.core.map.TableMap; +import cn.hutool.core.util.ArrayUtil; import java.io.Serializable; import java.lang.annotation.Annotation; @@ -116,6 +117,10 @@ public class CombinationAnnotationElement implements AnnotatedElement, Serializa * @param annotations Class, Method, Field等 */ private void parseDeclared(Annotation[] annotations) { + if(ArrayUtil.isEmpty(annotations)){ + return; + } + Class annotationType; // 直接注解 for (Annotation annotation : annotations) { @@ -138,6 +143,10 @@ public class CombinationAnnotationElement implements AnnotatedElement, Serializa * @param annotations Class, Method, Field等 */ private void parse(Annotation[] annotations) { + if(ArrayUtil.isEmpty(annotations)){ + return; + } + Class annotationType; for (Annotation annotation : annotations) { annotationType = annotation.annotationType();