|
22 | 22 |
|
23 | 23 | import org.springframework.core.annotation.AnnotationConfigurationException;
|
24 | 24 | import org.springframework.security.access.prepost.PreAuthorize;
|
| 25 | +import org.springframework.util.ClassUtils; |
25 | 26 |
|
26 | 27 | import static org.assertj.core.api.Assertions.assertThat;
|
27 | 28 | import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
|
@@ -275,6 +276,14 @@ void scanWhenAnnotationOnParameterizedMethodThenLocates() throws Exception {
|
275 | 276 | assertThat(pre).isNotNull();
|
276 | 277 | }
|
277 | 278 |
|
| 279 | + // gh-17898 |
| 280 | + @Test |
| 281 | + void scanWhenAnnotationOnParameterizedUndeclaredMethodAndThenLocates() throws Exception { |
| 282 | + Method method = ClassUtils.getMethod(GenericInterfaceImpl.class, "processOneAndTwo", Long.class, Object.class); |
| 283 | + PreAuthorize pre = this.scanner.scan(method, method.getDeclaringClass()); |
| 284 | + assertThat(pre).isNotNull(); |
| 285 | + } |
| 286 | + |
278 | 287 | @PreAuthorize("one")
|
279 | 288 | private interface AnnotationOnInterface {
|
280 | 289 |
|
@@ -637,4 +646,27 @@ <S extends Number> S getExtByClass(Class<S> clazz, Long l) {
|
637 | 646 |
|
638 | 647 | }
|
639 | 648 |
|
| 649 | + interface GenericInterface<A, B> { |
| 650 | + |
| 651 | + @PreAuthorize("hasAuthority('thirtythree')") |
| 652 | + void processOneAndTwo(A value1, B value2); |
| 653 | + |
| 654 | + } |
| 655 | + |
| 656 | + abstract static class GenericAbstractSuperclass<C> implements GenericInterface<Long, C> { |
| 657 | + |
| 658 | + @Override |
| 659 | + public void processOneAndTwo(Long value1, C value2) { |
| 660 | + } |
| 661 | + |
| 662 | + } |
| 663 | + |
| 664 | + static class GenericInterfaceImpl extends GenericAbstractSuperclass<String> { |
| 665 | + |
| 666 | + // The compiler does not require us to declare a concrete |
| 667 | + // processOneAndTwo(Long, String) method, and we intentionally |
| 668 | + // do not declare one here. |
| 669 | + |
| 670 | + } |
| 671 | + |
640 | 672 | }
|
0 commit comments