fix: addressing possible npes (#41944)

close: #40659

Signed-off-by: Steve Hawkins <shawkins@redhat.com>
This commit is contained in:
Steven Hawkins
2025-08-18 17:51:17 -04:00
committed by GitHub
parent ec48a4d735
commit 2ce3474ed5
5 changed files with 23 additions and 5 deletions

View File

@@ -436,16 +436,13 @@ public class ReflectionUtil {
}
public static String getTypeString(Type type, Field field) {
Class clazz = null;
if (type == null) {
if (field == null) {
throw new IllegalArgumentException("type == null and field == null");
}
type = field.getGenericType();
}
if (type instanceof Class) {
clazz = (Class) type;
} else if (type instanceof ParameterizedType) {
if (type instanceof ParameterizedType) {
StringBuilder sb = new StringBuilder();
String rtype = getTypeString(((ParameterizedType) type).getRawType(), null);
@@ -463,6 +460,12 @@ public class ReflectionUtil {
return sb.toString();
}
if (!(type instanceof Class)) {
throw new IllegalArgumentException("unsupported type " + type.getClass().getName());
}
Class clazz = (Class) type;
if (CharSequence.class.isAssignableFrom(clazz)) {
return "string";
} else if (Integer.class.isAssignableFrom(clazz) || int.class.isAssignableFrom(clazz)) {