Skip to content

Commit a3b8290

Browse files
authored
Merge pull request #1922 from cyuyang/fix-superclass
fix: check existence of superclass before accessing its name
2 parents 3131189 + 9d2b200 commit a3b8290

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

springdoc-openapi-common/src/main/java/org/springdoc/core/MethodParameterPojoExtractor.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -174,9 +174,8 @@ private static Stream<MethodParameter> fromSimpleClass(Class<?> paramClass, Fiel
174174
try {
175175
Parameter parameter = field.getAnnotation(Parameter.class);
176176
boolean isNotRequired = parameter == null || !parameter.required();
177-
Annotation[] finalFieldAnnotations = fieldAnnotations;
178177

179-
if ("java.lang.Record".equals(paramClass.getSuperclass().getName())) {
178+
if (paramClass.getSuperclass() != null && "java.lang.Record".equals(paramClass.getSuperclass().getName())) {
180179
Method classGetRecordComponents = Class.class.getMethod("getRecordComponents");
181180
Object[] components = (Object[]) classGetRecordComponents.invoke(paramClass);
182181

@@ -191,7 +190,7 @@ private static Stream<MethodParameter> fromSimpleClass(Class<?> paramClass, Fiel
191190
.filter(method -> method.getName().equals(field.getName()))
192191
.map(method -> new MethodParameter(method, -1))
193192
.map(methodParameter -> DelegatingMethodParameter.changeContainingClass(methodParameter, paramClass))
194-
.map(param -> new DelegatingMethodParameter(param, fieldNamePrefix + field.getName(), finalFieldAnnotations, true, isNotRequired));
193+
.map(param -> new DelegatingMethodParameter(param, fieldNamePrefix + field.getName(), fieldAnnotations, true, isNotRequired));
195194

196195
}
197196
else
@@ -201,7 +200,7 @@ private static Stream<MethodParameter> fromSimpleClass(Class<?> paramClass, Fiel
201200
.filter(Objects::nonNull)
202201
.map(method -> new MethodParameter(method, -1))
203202
.map(methodParameter -> DelegatingMethodParameter.changeContainingClass(methodParameter, paramClass))
204-
.map(param -> new DelegatingMethodParameter(param, fieldNamePrefix + field.getName(), finalFieldAnnotations, true, isNotRequired));
203+
.map(param -> new DelegatingMethodParameter(param, fieldNamePrefix + field.getName(), fieldAnnotations, true, isNotRequired));
205204
}
206205
catch (IntrospectionException | NoSuchMethodException |
207206
InvocationTargetException | IllegalAccessException |

0 commit comments

Comments
 (0)