Skip to content

Commit a159dd1

Browse files
committed
Fix checkstyle issues and compiler warnings.
1 parent b2f8753 commit a159dd1

File tree

2 files changed

+34
-15
lines changed

2 files changed

+34
-15
lines changed

spring-aop/src/main/java/org/springframework/aop/framework/CglibAopProxy.java

-2
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
import java.io.Serializable;
2020
import java.lang.reflect.Method;
2121
import java.lang.reflect.Modifier;
22-
import java.lang.reflect.UndeclaredThrowableException;
2322
import java.util.ArrayList;
2423
import java.util.Collections;
2524
import java.util.List;
@@ -54,7 +53,6 @@
5453
import org.springframework.util.ClassUtils;
5554
import org.springframework.util.CollectionUtils;
5655
import org.springframework.util.ObjectUtils;
57-
import org.springframework.util.ReflectionUtils;
5856

5957
/**
6058
* CGLIB-based {@link AopProxy} implementation for the Spring AOP framework.

spring-aop/src/test/java/org/springframework/aop/framework/ProxyExceptionHandlingTests.java

+34-13
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,41 @@
1-
package org.springframework.aop.framework;
1+
/*
2+
* Copyright 2002-2024 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+
*/
216

3-
import static java.util.Objects.requireNonNull;
4-
import static org.mockito.Mockito.doAnswer;
5-
import static org.mockito.Mockito.doThrow;
6-
import static org.mockito.Mockito.mock;
17+
package org.springframework.aop.framework;
718

19+
import java.io.Serial;
820
import java.lang.reflect.Proxy;
921
import java.lang.reflect.UndeclaredThrowableException;
10-
import java.util.Collection;
11-
import java.util.Set;
22+
import java.util.Objects;
1223

13-
import org.aopalliance.aop.Advice;
1424
import org.aopalliance.intercept.MethodInterceptor;
1525
import org.assertj.core.api.WithAssertions;
1626
import org.junit.jupiter.api.BeforeEach;
1727
import org.junit.jupiter.api.Nested;
1828
import org.junit.jupiter.api.Test;
1929
import org.mockito.Mockito;
2030
import org.mockito.stubbing.Answer;
31+
2132
import org.springframework.cglib.proxy.Enhancer;
2233
import org.springframework.lang.Nullable;
2334

35+
import static org.mockito.BDDMockito.doAnswer;
36+
import static org.mockito.BDDMockito.doThrow;
37+
import static org.mockito.BDDMockito.mock;
38+
2439
abstract class ProxyExceptionHandlingTests implements WithAssertions {
2540

2641
private static final RuntimeException uncheckedException = new RuntimeException();
@@ -35,7 +50,7 @@ abstract class ProxyExceptionHandlingTests implements WithAssertions {
3550
@Nullable
3651
private Throwable throwableSeenByCaller;
3752

38-
static class ObjenesisCglibAopProxyTest extends ProxyExceptionHandlingTests {
53+
static class ObjenesisCglibAopProxyTests extends ProxyExceptionHandlingTests {
3954
@BeforeEach
4055
void beforeEach() {
4156
proxyFactory.setProxyTargetClass(true);
@@ -47,14 +62,15 @@ protected void assertProxyType(Object proxy) {
4762
}
4863
}
4964

50-
static class JdkAopProxyTest extends ProxyExceptionHandlingTests {
65+
static class JdkAopProxyTests extends ProxyExceptionHandlingTests {
5166
@Override
5267
protected void assertProxyType(Object proxy) {
5368
assertThat(Proxy.isProxyClass(proxy.getClass())).isTrue();
5469
}
5570
}
5671

57-
protected void assertProxyType(Object proxy) {};
72+
protected void assertProxyType(Object proxy) {
73+
}
5874

5975
@BeforeEach
6076
void beforeEach() {
@@ -112,7 +128,8 @@ private MethodInterceptor captureThrowable() {
112128
return invocation -> {
113129
try {
114130
return invocation.proceed();
115-
} catch (Exception e) {
131+
}
132+
catch (Exception e) {
116133
throwableSeenByInterceptor = e;
117134
throw e;
118135
}
@@ -161,7 +178,7 @@ void targetThrowsUncheckedException() throws DeclaredCheckedException {
161178
}
162179

163180
private void invokeProxy() {
164-
throwableSeenByCaller = catchThrowable(() -> requireNonNull(proxy).doSomething());
181+
throwableSeenByCaller = catchThrowable(() -> Objects.requireNonNull(proxy).doSomething());
165182
}
166183

167184
private Answer<?> sneakyThrow(@SuppressWarnings("SameParameterValue") Throwable throwable) {
@@ -182,9 +199,13 @@ protected interface MyInterface {
182199
}
183200

184201
protected static class UndeclaredCheckedException extends Exception {
202+
@Serial
203+
private static final long serialVersionUID = -4199611059122356651L;
185204
}
186205

187206
protected static class DeclaredCheckedException extends Exception {
207+
@Serial
208+
private static final long serialVersionUID = 8851375818059230518L;
188209
}
189210

190211
}

0 commit comments

Comments
 (0)