Skip to content

Commit 8c74d6c

Browse files
Alexander Furerjzheaux
authored andcommitted
Fix isAssignable order
Closes spring-projectsgh-10236
1 parent e36e2b2 commit 8c74d6c

File tree

2 files changed

+62
-2
lines changed

2 files changed

+62
-2
lines changed

core/src/main/java/org/springframework/security/access/prepost/PostInvocationAdviceProvider.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2016 the original author or authors.
2+
* Copyright 2002-2021 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -34,6 +34,7 @@
3434
* annotations.
3535
*
3636
* @author Luke Taylor
37+
* @author Alexander Furer
3738
* @since 3.0
3839
*/
3940
public class PostInvocationAdviceProvider implements AfterInvocationProvider {
@@ -73,7 +74,7 @@ public boolean supports(ConfigAttribute attribute) {
7374

7475
@Override
7576
public boolean supports(Class<?> clazz) {
76-
return clazz.isAssignableFrom(MethodInvocation.class);
77+
return MethodInvocation.class.isAssignableFrom(clazz);
7778
}
7879

7980
}
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
/*
2+
* Copyright 2002-2021 the original author or authors.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package org.springframework.security.access.prepost;
18+
19+
import org.aopalliance.intercept.MethodInvocation;
20+
import org.junit.jupiter.api.BeforeEach;
21+
import org.junit.jupiter.api.Test;
22+
import org.junit.jupiter.api.extension.ExtendWith;
23+
import org.mockito.Mock;
24+
import org.mockito.junit.jupiter.MockitoExtension;
25+
26+
import org.springframework.aop.ProxyMethodInvocation;
27+
import org.springframework.security.access.intercept.aspectj.MethodInvocationAdapter;
28+
29+
import static org.assertj.core.api.Assertions.assertThat;
30+
31+
@ExtendWith(MockitoExtension.class)
32+
public class PostInvocationAdviceProviderTest {
33+
34+
@Mock
35+
private PostInvocationAuthorizationAdvice authorizationAdvice;
36+
37+
private PostInvocationAdviceProvider postInvocationAdviceProvider;
38+
39+
@BeforeEach
40+
public void setUp() {
41+
this.postInvocationAdviceProvider = new PostInvocationAdviceProvider(this.authorizationAdvice);
42+
}
43+
44+
@Test
45+
public void supportsMethodInvocation() {
46+
assertThat(this.postInvocationAdviceProvider.supports(MethodInvocation.class)).isTrue();
47+
}
48+
49+
@Test
50+
public void supportsProxyMethodInvocation() {
51+
assertThat(this.postInvocationAdviceProvider.supports(ProxyMethodInvocation.class)).isTrue();
52+
}
53+
54+
@Test
55+
public void supportsMethodInvocationAdapter() {
56+
assertThat(this.postInvocationAdviceProvider.supports(MethodInvocationAdapter.class)).isTrue();
57+
}
58+
59+
}

0 commit comments

Comments
 (0)