-
Notifications
You must be signed in to change notification settings - Fork 38.8k
Description
Sebastian Dietrich opened SPR-12604 and commented
If annotation is null this method throws a NullPointerException and catches it to return null. This method is called frequently with annotation==null - at least in my case (using spring-data to findById)
Please rewrite it to:
public static Object getValue(Annotation annotation, String attributeName) {
if (annotation == null) return null;
try {
Method method = annotation.annotationType().getDeclaredMethod(attributeName);
ReflectionUtils.makeAccessible(method);
return method.invoke(annotation);
}
catch (Exception ex) {
return null;
}
}
here is the end of the corresponding stack:
AnnotationUtils.getValue(Annotation, String) line: 642
AnnotationUtils.getValue(Annotation) line: 630
JpaQueryMethod.getLockModeType() line: 164
PartTreeJpaQuery(AbstractJpaQuery).applyLockMode(Query, JpaQueryMethod) line: 155
PartTreeJpaQuery(AbstractJpaQuery).createQuery(Object[]) line: 164
JpaQueryExecution$SingleEntityExecution.doExecute(AbstractJpaQuery, Object[]) line: 202
JpaQueryExecution$SingleEntityExecution(JpaQueryExecution).execute(AbstractJpaQuery, Object[]) line: 74
...
Affects: 4.0.8