Skip to content

Commit 333af51

Browse files
author
Vincent Potucek
committed
fix ignored exceptions
Signed-off-by: Vincent Potucek <[email protected]>
1 parent d8ac3ff commit 333af51

File tree

18 files changed

+25
-50
lines changed

18 files changed

+25
-50
lines changed

integration-tests/src/test/java/org/springframework/aop/framework/autoproxy/AdvisorAutoProxyCreatorIntegrationTests.java

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -158,8 +158,7 @@ void testRollbackRulesOnMethodPreventRollback() throws Exception {
158158
try {
159159
rb.echoException(new ServletException());
160160
}
161-
catch (ServletException ex) {
162-
161+
catch (ServletException ignored) {
163162
}
164163
assertThat(txMan.commits).as("Transaction counts match").isEqualTo(1);
165164
}
@@ -272,9 +271,7 @@ public void before(Method method, Object[] args, Object target) throws Throwable
272271
TransactionInterceptor.currentTransactionStatus();
273272
throw new RuntimeException("Shouldn't have a transaction");
274273
}
275-
catch (NoTransactionException ex) {
276-
// this is Ok
277-
}
274+
catch (NoTransactionException ignored) { } // this is Ok
278275
}
279276
super.before(method, args, target);
280277
}

spring-aop/src/main/java/org/springframework/aop/aspectj/AspectJExpressionPointcut.java

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -453,10 +453,9 @@ private ShadowMatch getTargetShadowMatch(Method method, Class<?> targetClass) {
453453
ClassUtils.toClassArray(ifcs), targetClass.getClassLoader());
454454
targetMethod = ClassUtils.getMostSpecificMethod(targetMethod, compositeInterface);
455455
}
456-
catch (IllegalArgumentException ex) {
457-
// Implemented interfaces probably expose conflicting method signatures...
458-
// Proceed with original target method.
459-
}
456+
catch (IllegalArgumentException ignored) { }
457+
// Implemented interfaces probably expose conflicting method signatures...
458+
// Proceed with original target method.
460459
}
461460
}
462461
return getShadowMatch(targetMethod, method);
@@ -478,7 +477,7 @@ private ShadowMatch getShadowMatch(Method targetMethod, Method originalMethod) {
478477
try {
479478
shadowMatch = pointcutExpression.matchesMethodExecution(methodToMatch);
480479
}
481-
catch (ReflectionWorldException ex) {
480+
catch (ReflectionWorldException ignored) {
482481
// Failed to introspect target method, probably because it has been loaded
483482
// in a special ClassLoader. Let's try the declaring ClassLoader instead...
484483
try {
@@ -501,7 +500,7 @@ private ShadowMatch getShadowMatch(Method targetMethod, Method originalMethod) {
501500
try {
502501
shadowMatch = pointcutExpression.matchesMethodExecution(methodToMatch);
503502
}
504-
catch (ReflectionWorldException ex) {
503+
catch (ReflectionWorldException ignored) {
505504
// Could neither introspect the target class nor the proxy class ->
506505
// let's try the original method's declaring class before we give up...
507506
try {

spring-context/src/test/java/org/springframework/aop/framework/AbstractAopProxyTests.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -233,8 +233,7 @@ void serializableTargetAndAdvice() throws Throwable {
233233
try {
234234
p2.echo(new IOException());
235235
}
236-
catch (IOException ex) {
237-
236+
catch (IOException ignored) {
238237
}
239238
assertThat(cta.getCalls()).isEqualTo(2);
240239
}

spring-core/src/main/java/org/springframework/util/FileCopyUtils.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -229,8 +229,7 @@ private static void close(Closeable closeable) {
229229
try {
230230
closeable.close();
231231
}
232-
catch (IOException ex) {
233-
// ignore
232+
catch (IOException ignored) {
234233
}
235234
}
236235

spring-test/src/main/java/org/springframework/mock/http/client/MockClientHttpResponse.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,8 +100,7 @@ public void close() {
100100
try {
101101
getBody().close();
102102
}
103-
catch (IOException ex) {
104-
// ignore
103+
catch (IOException ignored) {
105104
}
106105
}
107106

spring-web/src/main/java/org/springframework/http/client/HttpComponentsClientHttpResponse.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,8 +89,7 @@ public void close() {
8989
this.httpResponse.close();
9090
}
9191
}
92-
catch (IOException ex) {
93-
// Ignore exception on close...
92+
catch (IOException ignored) {
9493
}
9594
}
9695

spring-web/src/main/java/org/springframework/http/client/ReactorClientHttpResponse.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -108,8 +108,7 @@ public void close() {
108108
StreamUtils.drain(body);
109109
body.close();
110110
}
111-
catch (IOException ex) {
112-
// ignore
111+
catch (IOException ignored) {
113112
}
114113
}
115114

spring-web/src/main/java/org/springframework/http/converter/ResourceHttpMessageConverter.java

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -158,21 +158,15 @@ protected void writeContent(Resource resource, HttpOutputMessage outputMessage)
158158
in.transferTo(out);
159159
out.flush();
160160
}
161-
catch (NullPointerException ex) {
162-
// ignore, see SPR-13620
163-
}
161+
catch (NullPointerException ignored) { } // ignore, see SPR-13620
164162
finally {
165163
try {
166164
in.close();
167165
}
168-
catch (Throwable ex) {
169-
// ignore, see SPR-12999
170-
}
166+
catch (Throwable ignored) { } // ignore, see SPR-12999
171167
}
172168
}
173-
catch (FileNotFoundException ex) {
174-
// ignore, see SPR-12999
175-
}
169+
catch (FileNotFoundException ignored) { } // ignore, see SPR-12999
176170
}
177171

178172
}

spring-web/src/main/java/org/springframework/http/converter/ResourceRegionHttpMessageConverter.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -183,9 +183,7 @@ protected void writeResourceRegion(ResourceRegion region, HttpOutputMessage outp
183183
try {
184184
in.close();
185185
}
186-
catch (IOException ex) {
187-
// ignore
188-
}
186+
catch (IOException ignored) { }
189187
}
190188
}
191189

spring-web/src/main/java/org/springframework/web/client/HttpMessageConverterExtractor.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -152,8 +152,7 @@ private static byte[] getResponseBody(ClientHttpResponse response) {
152152
try {
153153
return FileCopyUtils.copyToByteArray(response.getBody());
154154
}
155-
catch (IOException ex) {
156-
// ignore
155+
catch (IOException ignored) {
157156
}
158157
return new byte[0];
159158
}

spring-web/src/test/java/org/springframework/web/context/request/RequestContextListenerTests.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ void requestContextListenerWithDifferentThread() {
9393
try {
9494
thread.join();
9595
}
96-
catch (InterruptedException ex) {
96+
catch (InterruptedException ignored) {
9797
}
9898
// Still bound to original thread, but at least completed.
9999
assertThat(RequestContextHolder.getRequestAttributes()).isNotNull();

spring-web/src/testFixtures/java/org/springframework/web/testfixture/http/client/MockClientHttpResponse.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,8 +100,7 @@ public void close() {
100100
try {
101101
getBody().close();
102102
}
103-
catch (IOException ex) {
104-
// ignore
103+
catch (IOException ignored) {
105104
}
106105
}
107106

spring-webflux/src/main/java/org/springframework/web/reactive/resource/ResourceHandlerUtils.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,8 +76,7 @@ else if (location instanceof UrlResource) {
7676
Assert.isTrue(path.endsWith(FOLDER_SEPARATOR) || path.endsWith(WINDOWS_FOLDER_SEPARATOR),
7777
"Resource location does not end with slash: " + path);
7878
}
79-
catch (IOException ex) {
80-
// ignore
79+
catch (IOException ignored) {
8180
}
8281
}
8382

spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/method/annotation/RequestPartMethodArgumentResolver.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -191,8 +191,7 @@ void closeStreamIfNecessary(InputStream body) {
191191
try {
192192
body.close();
193193
}
194-
catch (IOException ex) {
195-
// ignore
194+
catch (IOException ignored) {
196195
}
197196
}
198197

spring-webmvc/src/main/java/org/springframework/web/servlet/resource/ResourceHandlerUtils.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,8 +77,7 @@ else if (location instanceof UrlResource) {
7777
Assert.isTrue(path.endsWith(FOLDER_SEPARATOR) || path.endsWith(WINDOWS_FOLDER_SEPARATOR),
7878
"Resource location does not end with slash: " + path);
7979
}
80-
catch (IOException ex) {
81-
// ignore
80+
catch (IOException ignored) {
8281
}
8382
}
8483

spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/ExceptionHandlerExceptionResolverTests.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -611,8 +611,7 @@ static class ResponseStatusTestExceptionResolver {
611611

612612
@ExceptionHandler(SocketTimeoutException.class)
613613
@ResponseStatus(code = HttpStatus.GATEWAY_TIMEOUT, reason = "gateway.timeout")
614-
public void handleException(SocketTimeoutException ex) {
615-
614+
public void handleException(SocketTimeoutException ignored) {
616615
}
617616
}
618617

spring-websocket/src/main/java/org/springframework/web/socket/handler/BinaryWebSocketHandler.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,7 @@ protected void handleTextMessage(WebSocketSession session, TextMessage message)
4141
try {
4242
session.close(CloseStatus.NOT_ACCEPTABLE.withReason("Text messages not supported"));
4343
}
44-
catch (IOException ex) {
45-
// ignore
44+
catch (IOException ignored) {
4645
}
4746
}
4847

spring-websocket/src/main/java/org/springframework/web/socket/handler/TextWebSocketHandler.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,7 @@ protected void handleBinaryMessage(WebSocketSession session, BinaryMessage messa
4141
try {
4242
session.close(CloseStatus.NOT_ACCEPTABLE.withReason("Binary messages not supported"));
4343
}
44-
catch (IOException ex) {
45-
// ignore
44+
catch (IOException ignored) {
4645
}
4746
}
4847

0 commit comments

Comments
 (0)