Align Method Traversal with MergedAnnotations

Closes gh-16751
This commit is contained in:
Josh Cummings
2025-01-08 14:22:31 -07:00
parent 4993fa863a
commit dc2e1af2da
2 changed files with 115 additions and 7 deletions

View File

@@ -251,6 +251,30 @@ public class UniqueSecurityAnnotationScannerTests {
assertThat(preAuthorize).isNull();
}
// gh-16751
@Test
void scanWhenAnnotationOnParameterizedInterfaceTheLocates() throws Exception {
Method method = MyServiceImpl.class.getDeclaredMethod("get", String.class);
PreAuthorize pre = this.scanner.scan(method, method.getDeclaringClass());
assertThat(pre).isNotNull();
}
// gh-16751
@Test
void scanWhenAnnotationOnParameterizedSuperClassThenLocates() throws Exception {
Method method = MyServiceImpl.class.getDeclaredMethod("getExt", Long.class);
PreAuthorize pre = this.scanner.scan(method, method.getDeclaringClass());
assertThat(pre).isNotNull();
}
// gh-16751
@Test
void scanWhenAnnotationOnParameterizedMethodThenLocates() throws Exception {
Method method = MyServiceImpl.class.getDeclaredMethod("getExtByClass", Class.class, Long.class);
PreAuthorize pre = this.scanner.scan(method, method.getDeclaringClass());
assertThat(pre).isNotNull();
}
@PreAuthorize("one")
private interface AnnotationOnInterface {
@@ -577,4 +601,40 @@ public class UniqueSecurityAnnotationScannerTests {
}
interface MyService<C, U> {
@PreAuthorize("thirty")
C get(U u);
}
abstract static class MyServiceExt<T> implements MyService<Integer, String> {
@PreAuthorize("thirtyone")
abstract T getExt(T t);
@PreAuthorize("thirtytwo")
abstract <S extends Number> S getExtByClass(Class<S> clazz, T t);
}
static class MyServiceImpl extends MyServiceExt<Long> {
@Override
public Integer get(final String s) {
return 0;
}
@Override
Long getExt(Long o) {
return 0L;
}
@Override
<S extends Number> S getExtByClass(Class<S> clazz, Long l) {
return null;
}
}
}