From 0d4dfb6c1f724f9b9081de58d480856b88e4e416 Mon Sep 17 00:00:00 2001 From: Vincent Potucek Date: Fri, 13 Jun 2025 16:03:24 +0200 Subject: [PATCH] Rename exception variables in empty catch blocks The Spring codebase sometimes ignores exceptions in catch blocks on purpose. This is often called out by an inline comment. We should make this more obvious by renaming the exception argument in the catch block to declare whether the exception is "ignored" or "expected". See gh-35047 Signed-off-by: Vincent Potucek [brian.clozel@broadcom.com: rework commit message] Signed-off-by: Brian Clozel --- .../AdvisorAutoProxyCreatorIntegrationTests.java | 5 ++--- .../aop/aspectj/AspectJExpressionPointcut.java | 10 +++++----- .../annotation/BeanFactoryAnnotationUtils.java | 4 ++-- .../support/PostProcessorRegistrationDelegate.java | 3 +-- .../beanvalidation/LocalValidatorFactoryBean.java | 8 ++++---- .../aop/framework/AbstractAopProxyTests.java | 3 +-- .../CompileWithForkedClassLoaderClassLoader.java | 3 +-- .../cglib/proxy/BridgeMethodResolver.java | 3 ++- .../org/springframework/cglib/proxy/MethodProxy.java | 4 ++-- .../core/io/support/SpringFactoriesLoader.java | 3 +-- .../java/org/springframework/util/FileCopyUtils.java | 3 +-- .../messaging/simp/stomp/DefaultStompSession.java | 3 +-- .../springframework/oxm/jaxb/Jaxb2Marshaller.java | 3 +-- .../connection/R2dbcTransactionManagerTests.java | 3 +-- .../mock/http/client/MockClientHttpResponse.java | 3 +-- .../mock/web/MockHttpServletRequest.java | 3 +-- .../java/org/springframework/http/HttpHeaders.java | 3 +-- .../client/HttpComponentsClientHttpResponse.java | 3 +-- .../http/client/ReactorClientHttpResponse.java | 3 +-- .../reactive/HttpComponentsClientHttpResponse.java | 3 +-- .../http/converter/ResourceHttpMessageConverter.java | 12 ++++++------ .../ResourceRegionHttpMessageConverter.java | 6 ++---- .../converter/xml/SourceHttpMessageConverter.java | 3 +-- .../reactive/AbstractListenerWriteProcessor.java | 3 +-- .../server/reactive/ServletHttpHandlerAdapter.java | 9 +++------ .../web/client/HttpMessageConverterExtractor.java | 3 +-- .../request/async/CallableInterceptorChain.java | 3 +-- .../async/StandardServletAsyncWebRequest.java | 3 +-- .../web/context/support/ServletContextResource.java | 3 +-- .../HttpServiceProxyRegistryFactoryBean.java | 3 +-- .../context/request/RequestContextListenerTests.java | 2 +- .../http/client/MockClientHttpResponse.java | 3 +-- .../testfixture/servlet/MockHttpServletRequest.java | 3 +-- .../web/reactive/function/client/WebClientUtils.java | 3 +-- .../function/server/DefaultServerRequestBuilder.java | 6 ++---- .../web/reactive/resource/ResourceHandlerUtils.java | 3 +-- .../result/condition/ProducesRequestCondition.java | 3 +-- .../method/annotation/MvcUriComponentsBuilder.java | 3 +-- .../annotation/RequestMappingHandlerAdapter.java | 3 +-- .../RequestPartMethodArgumentResolver.java | 3 +-- .../web/servlet/resource/ResourceHandlerUtils.java | 3 +-- .../ExceptionHandlerExceptionResolverTests.java | 3 +-- .../web/socket/handler/BinaryWebSocketHandler.java | 3 +-- .../handler/ExceptionWebSocketHandlerDecorator.java | 3 +-- .../web/socket/handler/TextWebSocketHandler.java | 3 +-- .../socket/messaging/StompSubProtocolHandler.java | 3 +-- 46 files changed, 66 insertions(+), 108 deletions(-) diff --git a/integration-tests/src/test/java/org/springframework/aop/framework/autoproxy/AdvisorAutoProxyCreatorIntegrationTests.java b/integration-tests/src/test/java/org/springframework/aop/framework/autoproxy/AdvisorAutoProxyCreatorIntegrationTests.java index b416fc3edf7..a7aec02b83a 100644 --- a/integration-tests/src/test/java/org/springframework/aop/framework/autoproxy/AdvisorAutoProxyCreatorIntegrationTests.java +++ b/integration-tests/src/test/java/org/springframework/aop/framework/autoproxy/AdvisorAutoProxyCreatorIntegrationTests.java @@ -158,8 +158,7 @@ class AdvisorAutoProxyCreatorIntegrationTests { try { rb.echoException(new ServletException()); } - catch (ServletException ex) { - + catch (ServletException ignored) { } assertThat(txMan.commits).as("Transaction counts match").isEqualTo(1); } @@ -272,7 +271,7 @@ class OrderedTxCheckAdvisor extends StaticMethodMatcherPointcutAdvisor implement TransactionInterceptor.currentTransactionStatus(); throw new RuntimeException("Shouldn't have a transaction"); } - catch (NoTransactionException ex) { + catch (NoTransactionException ignored) { // this is Ok } } diff --git a/spring-aop/src/main/java/org/springframework/aop/aspectj/AspectJExpressionPointcut.java b/spring-aop/src/main/java/org/springframework/aop/aspectj/AspectJExpressionPointcut.java index b1b196243bf..3efbc972772 100644 --- a/spring-aop/src/main/java/org/springframework/aop/aspectj/AspectJExpressionPointcut.java +++ b/spring-aop/src/main/java/org/springframework/aop/aspectj/AspectJExpressionPointcut.java @@ -453,9 +453,9 @@ public class AspectJExpressionPointcut extends AbstractExpressionPointcut ClassUtils.toClassArray(ifcs), targetClass.getClassLoader()); targetMethod = ClassUtils.getMostSpecificMethod(targetMethod, compositeInterface); } - catch (IllegalArgumentException ex) { - // Implemented interfaces probably expose conflicting method signatures... - // Proceed with original target method. + // Implemented interfaces probably expose conflicting method signatures... + // Proceed with original target method. + catch (IllegalArgumentException ignored) { } } } @@ -478,7 +478,7 @@ public class AspectJExpressionPointcut extends AbstractExpressionPointcut try { shadowMatch = pointcutExpression.matchesMethodExecution(methodToMatch); } - catch (ReflectionWorldException ex) { + catch (ReflectionWorldException ignored) { // Failed to introspect target method, probably because it has been loaded // in a special ClassLoader. Let's try the declaring ClassLoader instead... try { @@ -501,7 +501,7 @@ public class AspectJExpressionPointcut extends AbstractExpressionPointcut try { shadowMatch = pointcutExpression.matchesMethodExecution(methodToMatch); } - catch (ReflectionWorldException ex) { + catch (ReflectionWorldException ignored) { // Could neither introspect the target class nor the proxy class -> // let's try the original method's declaring class before we give up... try { diff --git a/spring-beans/src/main/java/org/springframework/beans/factory/annotation/BeanFactoryAnnotationUtils.java b/spring-beans/src/main/java/org/springframework/beans/factory/annotation/BeanFactoryAnnotationUtils.java index df8ad91c32f..7387226831a 100644 --- a/spring-beans/src/main/java/org/springframework/beans/factory/annotation/BeanFactoryAnnotationUtils.java +++ b/spring-beans/src/main/java/org/springframework/beans/factory/annotation/BeanFactoryAnnotationUtils.java @@ -208,8 +208,8 @@ public abstract class BeanFactoryAnnotationUtils { } } } - catch (NoSuchBeanDefinitionException ex) { - // Ignore - can't compare qualifiers for a manually registered singleton object + catch (NoSuchBeanDefinitionException ignored) { + // can't compare qualifiers for a manually registered singleton object } } return false; diff --git a/spring-context/src/main/java/org/springframework/context/support/PostProcessorRegistrationDelegate.java b/spring-context/src/main/java/org/springframework/context/support/PostProcessorRegistrationDelegate.java index 63951ce330b..d8dbff7f328 100644 --- a/spring-context/src/main/java/org/springframework/context/support/PostProcessorRegistrationDelegate.java +++ b/spring-context/src/main/java/org/springframework/context/support/PostProcessorRegistrationDelegate.java @@ -523,8 +523,7 @@ final class PostProcessorRegistrationDelegate { try { typedStringValue.resolveTargetType(this.beanFactory.getBeanClassLoader()); } - catch (ClassNotFoundException ex) { - // ignore + catch (ClassNotFoundException ignored) { } } diff --git a/spring-context/src/main/java/org/springframework/validation/beanvalidation/LocalValidatorFactoryBean.java b/spring-context/src/main/java/org/springframework/validation/beanvalidation/LocalValidatorFactoryBean.java index b07d8ef7831..2c698a987ce 100644 --- a/spring-context/src/main/java/org/springframework/validation/beanvalidation/LocalValidatorFactoryBean.java +++ b/spring-context/src/main/java/org/springframework/validation/beanvalidation/LocalValidatorFactoryBean.java @@ -266,8 +266,8 @@ public class LocalValidatorFactoryBean extends SpringValidatorAdapter Method eclMethod = configuration.getClass().getMethod("externalClassLoader", ClassLoader.class); ReflectionUtils.invokeMethod(eclMethod, configuration, this.applicationContext.getClassLoader()); } - catch (NoSuchMethodException ex) { - // Ignore - no Hibernate Validator 5.2+ or similar provider + catch (NoSuchMethodException ignored) { + // no Hibernate Validator 5.2+ or similar provider } } @@ -417,8 +417,8 @@ public class LocalValidatorFactoryBean extends SpringValidatorAdapter try { return super.unwrap(type); } - catch (ValidationException ex) { - // Ignore - we'll try ValidatorFactory unwrapping next + catch (ValidationException ignored) { + // we'll try ValidatorFactory unwrapping next } } if (this.validatorFactory != null) { diff --git a/spring-context/src/test/java/org/springframework/aop/framework/AbstractAopProxyTests.java b/spring-context/src/test/java/org/springframework/aop/framework/AbstractAopProxyTests.java index b99c0c13ccc..7e54c19129d 100644 --- a/spring-context/src/test/java/org/springframework/aop/framework/AbstractAopProxyTests.java +++ b/spring-context/src/test/java/org/springframework/aop/framework/AbstractAopProxyTests.java @@ -233,8 +233,7 @@ abstract class AbstractAopProxyTests { try { p2.echo(new IOException()); } - catch (IOException ex) { - + catch (IOException ignored) { } assertThat(cta.getCalls()).isEqualTo(2); } diff --git a/spring-core-test/src/main/java/org/springframework/core/test/tools/CompileWithForkedClassLoaderClassLoader.java b/spring-core-test/src/main/java/org/springframework/core/test/tools/CompileWithForkedClassLoaderClassLoader.java index 36bf8512109..e13b16ee6c1 100644 --- a/spring-core-test/src/main/java/org/springframework/core/test/tools/CompileWithForkedClassLoaderClassLoader.java +++ b/spring-core-test/src/main/java/org/springframework/core/test/tools/CompileWithForkedClassLoaderClassLoader.java @@ -84,8 +84,7 @@ final class CompileWithForkedClassLoaderClassLoader extends ClassLoader { try (stream) { return stream.readAllBytes(); } - catch (IOException ex) { - // ignore + catch (IOException ignored) { } } return null; diff --git a/spring-core/src/main/java/org/springframework/cglib/proxy/BridgeMethodResolver.java b/spring-core/src/main/java/org/springframework/cglib/proxy/BridgeMethodResolver.java index 65fcf60600f..99f42c738e2 100644 --- a/spring-core/src/main/java/org/springframework/cglib/proxy/BridgeMethodResolver.java +++ b/spring-core/src/main/java/org/springframework/cglib/proxy/BridgeMethodResolver.java @@ -73,7 +73,8 @@ class BridgeMethodResolver { } finally { is.close(); } - } catch (IOException ignored) {} + } catch (IOException ignored) { + } } return resolved; } diff --git a/spring-core/src/main/java/org/springframework/cglib/proxy/MethodProxy.java b/spring-core/src/main/java/org/springframework/cglib/proxy/MethodProxy.java index de3e7de1b03..4c6050c8f98 100644 --- a/spring-core/src/main/java/org/springframework/cglib/proxy/MethodProxy.java +++ b/spring-core/src/main/java/org/springframework/cglib/proxy/MethodProxy.java @@ -62,8 +62,8 @@ public class MethodProxy { try { proxy.init(); } - catch (CodeGenerationException ex) { - // Ignore - to be retried when actually needed later on (possibly not at all) + catch (CodeGenerationException ignored) { + // to be retried when actually needed later on (possibly not at all) } } // SPRING PATCH END diff --git a/spring-core/src/main/java/org/springframework/core/io/support/SpringFactoriesLoader.java b/spring-core/src/main/java/org/springframework/core/io/support/SpringFactoriesLoader.java index c1228a05697..27725dda917 100644 --- a/spring-core/src/main/java/org/springframework/core/io/support/SpringFactoriesLoader.java +++ b/spring-core/src/main/java/org/springframework/core/io/support/SpringFactoriesLoader.java @@ -438,8 +438,7 @@ public class SpringFactoriesLoader { return constructor; } } - catch (UnsupportedOperationException ex) { - // ignore + catch (UnsupportedOperationException ignored) { } return null; } diff --git a/spring-core/src/main/java/org/springframework/util/FileCopyUtils.java b/spring-core/src/main/java/org/springframework/util/FileCopyUtils.java index 388ab5e3410..c2c729a25d6 100644 --- a/spring-core/src/main/java/org/springframework/util/FileCopyUtils.java +++ b/spring-core/src/main/java/org/springframework/util/FileCopyUtils.java @@ -229,8 +229,7 @@ public abstract class FileCopyUtils { try { closeable.close(); } - catch (IOException ex) { - // ignore + catch (IOException ignored) { } } diff --git a/spring-messaging/src/main/java/org/springframework/messaging/simp/stomp/DefaultStompSession.java b/spring-messaging/src/main/java/org/springframework/messaging/simp/stomp/DefaultStompSession.java index 84b549aaa40..5fecbc11e77 100644 --- a/spring-messaging/src/main/java/org/springframework/messaging/simp/stomp/DefaultStompSession.java +++ b/spring-messaging/src/main/java/org/springframework/messaging/simp/stomp/DefaultStompSession.java @@ -526,8 +526,7 @@ public class DefaultStompSession implements ConnectionHandlingStompSession { try { conn.close(); } - catch (Throwable ex) { - // ignore + catch (Throwable ignored) { } } } diff --git a/spring-oxm/src/main/java/org/springframework/oxm/jaxb/Jaxb2Marshaller.java b/spring-oxm/src/main/java/org/springframework/oxm/jaxb/Jaxb2Marshaller.java index 6f04669aa10..f48c0cfc160 100644 --- a/spring-oxm/src/main/java/org/springframework/oxm/jaxb/Jaxb2Marshaller.java +++ b/spring-oxm/src/main/java/org/springframework/oxm/jaxb/Jaxb2Marshaller.java @@ -1000,8 +1000,7 @@ public class Jaxb2Marshaller implements MimeMarshaller, MimeUnmarshaller, Generi URI uri = ResourceUtils.toURI(elementNamespace); return uri.getHost(); } - catch (URISyntaxException ex) { - // ignore + catch (URISyntaxException ignored) { } return dataHandler.getName(); } diff --git a/spring-r2dbc/src/test/java/org/springframework/r2dbc/connection/R2dbcTransactionManagerTests.java b/spring-r2dbc/src/test/java/org/springframework/r2dbc/connection/R2dbcTransactionManagerTests.java index b383b633b01..ab20840c7ff 100644 --- a/spring-r2dbc/src/test/java/org/springframework/r2dbc/connection/R2dbcTransactionManagerTests.java +++ b/spring-r2dbc/src/test/java/org/springframework/r2dbc/connection/R2dbcTransactionManagerTests.java @@ -710,8 +710,7 @@ class R2dbcTransactionManagerTests { try { return Mono.fromRunnable(() -> doAfterCompletion(status)); } - catch (Throwable ex) { - // ignore + catch (Throwable ignored) { } return Mono.empty(); diff --git a/spring-test/src/main/java/org/springframework/mock/http/client/MockClientHttpResponse.java b/spring-test/src/main/java/org/springframework/mock/http/client/MockClientHttpResponse.java index 328068f1116..a5f9e1aeac9 100644 --- a/spring-test/src/main/java/org/springframework/mock/http/client/MockClientHttpResponse.java +++ b/spring-test/src/main/java/org/springframework/mock/http/client/MockClientHttpResponse.java @@ -100,8 +100,7 @@ public class MockClientHttpResponse extends MockHttpInputMessage implements Clie try { getBody().close(); } - catch (IOException ex) { - // ignore + catch (IOException ignored) { } } diff --git a/spring-test/src/main/java/org/springframework/mock/web/MockHttpServletRequest.java b/spring-test/src/main/java/org/springframework/mock/web/MockHttpServletRequest.java index 35ee7c33265..9203a90a1c3 100644 --- a/spring-test/src/main/java/org/springframework/mock/web/MockHttpServletRequest.java +++ b/spring-test/src/main/java/org/springframework/mock/web/MockHttpServletRequest.java @@ -1129,8 +1129,7 @@ public class MockHttpServletRequest implements HttpServletRequest { try { return simpleDateFormat.parse(value).getTime(); } - catch (ParseException ex) { - // ignore + catch (ParseException ignored) { } } throw new IllegalArgumentException("Cannot parse date value '" + value + "' for '" + name + "' header"); diff --git a/spring-web/src/main/java/org/springframework/http/HttpHeaders.java b/spring-web/src/main/java/org/springframework/http/HttpHeaders.java index ee4d794e0e4..31426cb4d58 100644 --- a/spring-web/src/main/java/org/springframework/http/HttpHeaders.java +++ b/spring-web/src/main/java/org/springframework/http/HttpHeaders.java @@ -1223,8 +1223,7 @@ public class HttpHeaders implements Serializable { try { port = Integer.parseInt(portString); } - catch (NumberFormatException ex) { - // ignore + catch (NumberFormatException ignored) { } } diff --git a/spring-web/src/main/java/org/springframework/http/client/HttpComponentsClientHttpResponse.java b/spring-web/src/main/java/org/springframework/http/client/HttpComponentsClientHttpResponse.java index f7bb0814b83..5e7c3a63127 100644 --- a/spring-web/src/main/java/org/springframework/http/client/HttpComponentsClientHttpResponse.java +++ b/spring-web/src/main/java/org/springframework/http/client/HttpComponentsClientHttpResponse.java @@ -89,8 +89,7 @@ final class HttpComponentsClientHttpResponse implements ClientHttpResponse { this.httpResponse.close(); } } - catch (IOException ex) { - // Ignore exception on close... + catch (IOException ignored) { } } diff --git a/spring-web/src/main/java/org/springframework/http/client/ReactorClientHttpResponse.java b/spring-web/src/main/java/org/springframework/http/client/ReactorClientHttpResponse.java index b8bc57f4a26..e7397d39cac 100644 --- a/spring-web/src/main/java/org/springframework/http/client/ReactorClientHttpResponse.java +++ b/spring-web/src/main/java/org/springframework/http/client/ReactorClientHttpResponse.java @@ -108,8 +108,7 @@ final class ReactorClientHttpResponse implements ClientHttpResponse { StreamUtils.drain(body); body.close(); } - catch (IOException ex) { - // ignore + catch (IOException ignored) { } } diff --git a/spring-web/src/main/java/org/springframework/http/client/reactive/HttpComponentsClientHttpResponse.java b/spring-web/src/main/java/org/springframework/http/client/reactive/HttpComponentsClientHttpResponse.java index 98021ce6dd4..0abd5c73cae 100644 --- a/spring-web/src/main/java/org/springframework/http/client/reactive/HttpComponentsClientHttpResponse.java +++ b/spring-web/src/main/java/org/springframework/http/client/reactive/HttpComponentsClientHttpResponse.java @@ -119,8 +119,7 @@ class HttpComponentsClientHttpResponse extends AbstractClientHttpResponse { ZonedDateTime expiresDate = ZonedDateTime.parse(expiresAttribute, DateTimeFormatter.RFC_1123_DATE_TIME); return Duration.between(ZonedDateTime.now(expiresDate.getZone()), expiresDate).toSeconds(); } - catch (DateTimeParseException ex) { - // ignore + catch (DateTimeParseException ignored) { } } return -1; diff --git a/spring-web/src/main/java/org/springframework/http/converter/ResourceHttpMessageConverter.java b/spring-web/src/main/java/org/springframework/http/converter/ResourceHttpMessageConverter.java index 02bb193520e..d8a0b40fa83 100644 --- a/spring-web/src/main/java/org/springframework/http/converter/ResourceHttpMessageConverter.java +++ b/spring-web/src/main/java/org/springframework/http/converter/ResourceHttpMessageConverter.java @@ -158,20 +158,20 @@ public class ResourceHttpMessageConverter extends AbstractHttpMessageConverter extends AbstractHttpMe transform(t, new StreamResult(os)); return os.count; } - catch (TransformerException ex) { - // ignore + catch (TransformerException ignored) { } } return null; diff --git a/spring-web/src/main/java/org/springframework/http/server/reactive/AbstractListenerWriteProcessor.java b/spring-web/src/main/java/org/springframework/http/server/reactive/AbstractListenerWriteProcessor.java index 19f82840f30..dd4148f11c7 100644 --- a/spring-web/src/main/java/org/springframework/http/server/reactive/AbstractListenerWriteProcessor.java +++ b/spring-web/src/main/java/org/springframework/http/server/reactive/AbstractListenerWriteProcessor.java @@ -439,8 +439,7 @@ public abstract class AbstractListenerWriteProcessor implements Processor void onError(AbstractListenerWriteProcessor processor, Throwable ex) { - // ignore + public void onError(AbstractListenerWriteProcessor processor, Throwable ignored) { } @Override public void onComplete(AbstractListenerWriteProcessor processor) { diff --git a/spring-web/src/main/java/org/springframework/http/server/reactive/ServletHttpHandlerAdapter.java b/spring-web/src/main/java/org/springframework/http/server/reactive/ServletHttpHandlerAdapter.java index 44416259701..776a56f60df 100644 --- a/spring-web/src/main/java/org/springframework/http/server/reactive/ServletHttpHandlerAdapter.java +++ b/spring-web/src/main/java/org/springframework/http/server/reactive/ServletHttpHandlerAdapter.java @@ -309,8 +309,7 @@ public class ServletHttpHandlerAdapter implements Servlet { try { listener.onTimeout(event); } - catch (Exception ex) { - // Ignore + catch (Exception ignored) { } } @@ -318,8 +317,7 @@ public class ServletHttpHandlerAdapter implements Servlet { try { listener.onError(event); } - catch (Exception ex) { - // Ignore + catch (Exception ignored) { } } @@ -327,8 +325,7 @@ public class ServletHttpHandlerAdapter implements Servlet { try { listener.onComplete(event); } - catch (Exception ex) { - // Ignore + catch (Exception ignored) { } } diff --git a/spring-web/src/main/java/org/springframework/web/client/HttpMessageConverterExtractor.java b/spring-web/src/main/java/org/springframework/web/client/HttpMessageConverterExtractor.java index bf1077cd88c..ad482d3aced 100644 --- a/spring-web/src/main/java/org/springframework/web/client/HttpMessageConverterExtractor.java +++ b/spring-web/src/main/java/org/springframework/web/client/HttpMessageConverterExtractor.java @@ -152,8 +152,7 @@ public class HttpMessageConverterExtractor implements ResponseExtractor { try { return FileCopyUtils.copyToByteArray(response.getBody()); } - catch (IOException ex) { - // ignore + catch (IOException ignored) { } return new byte[0]; } diff --git a/spring-web/src/main/java/org/springframework/web/context/request/async/CallableInterceptorChain.java b/spring-web/src/main/java/org/springframework/web/context/request/async/CallableInterceptorChain.java index a78a9c9d54e..acf5c84206c 100644 --- a/spring-web/src/main/java/org/springframework/web/context/request/async/CallableInterceptorChain.java +++ b/spring-web/src/main/java/org/springframework/web/context/request/async/CallableInterceptorChain.java @@ -113,8 +113,7 @@ class CallableInterceptorChain { try { future.cancel(true); } - catch (Throwable ex) { - // Ignore + catch (Throwable ignored) { } } } diff --git a/spring-web/src/main/java/org/springframework/web/context/request/async/StandardServletAsyncWebRequest.java b/spring-web/src/main/java/org/springframework/web/context/request/async/StandardServletAsyncWebRequest.java index cf10f4d2c64..a8e731dbb2f 100644 --- a/spring-web/src/main/java/org/springframework/web/context/request/async/StandardServletAsyncWebRequest.java +++ b/spring-web/src/main/java/org/springframework/web/context/request/async/StandardServletAsyncWebRequest.java @@ -235,8 +235,7 @@ public class StandardServletAsyncWebRequest extends ServletWebRequest implements break; } } - catch (InterruptedException ex) { - // ignore + catch (InterruptedException ignored) { } } diff --git a/spring-web/src/main/java/org/springframework/web/context/support/ServletContextResource.java b/spring-web/src/main/java/org/springframework/web/context/support/ServletContextResource.java index d4aecb9507b..d8acddc5c7f 100644 --- a/spring-web/src/main/java/org/springframework/web/context/support/ServletContextResource.java +++ b/spring-web/src/main/java/org/springframework/web/context/support/ServletContextResource.java @@ -122,8 +122,7 @@ public class ServletContextResource extends AbstractFileResolvingResource implem try { is.close(); } - catch (IOException ex) { - // ignore + catch (IOException ignored) { } return true; } diff --git a/spring-web/src/main/java/org/springframework/web/service/registry/HttpServiceProxyRegistryFactoryBean.java b/spring-web/src/main/java/org/springframework/web/service/registry/HttpServiceProxyRegistryFactoryBean.java index 141bdd6fbd9..91408ee45f1 100644 --- a/spring-web/src/main/java/org/springframework/web/service/registry/HttpServiceProxyRegistryFactoryBean.java +++ b/spring-web/src/main/java/org/springframework/web/service/registry/HttpServiceProxyRegistryFactoryBean.java @@ -151,8 +151,7 @@ public final class HttpServiceProxyRegistryFactoryBean Class clazz = ClassUtils.forName(className, HttpServiceGroupAdapter.class.getClassLoader()); groupAdapters.put(clientType, (HttpServiceGroupAdapter) BeanUtils.instantiateClass(clazz)); } - catch (ClassNotFoundException ex) { - // ignore + catch (ClassNotFoundException ignored) { } } } diff --git a/spring-web/src/test/java/org/springframework/web/context/request/RequestContextListenerTests.java b/spring-web/src/test/java/org/springframework/web/context/request/RequestContextListenerTests.java index b433af80d61..9972563034d 100644 --- a/spring-web/src/test/java/org/springframework/web/context/request/RequestContextListenerTests.java +++ b/spring-web/src/test/java/org/springframework/web/context/request/RequestContextListenerTests.java @@ -93,7 +93,7 @@ class RequestContextListenerTests { try { thread.join(); } - catch (InterruptedException ex) { + catch (InterruptedException ignored) { } // Still bound to original thread, but at least completed. assertThat(RequestContextHolder.getRequestAttributes()).isNotNull(); diff --git a/spring-web/src/testFixtures/java/org/springframework/web/testfixture/http/client/MockClientHttpResponse.java b/spring-web/src/testFixtures/java/org/springframework/web/testfixture/http/client/MockClientHttpResponse.java index ae4f6464901..1287e40b298 100644 --- a/spring-web/src/testFixtures/java/org/springframework/web/testfixture/http/client/MockClientHttpResponse.java +++ b/spring-web/src/testFixtures/java/org/springframework/web/testfixture/http/client/MockClientHttpResponse.java @@ -100,8 +100,7 @@ public class MockClientHttpResponse extends MockHttpInputMessage implements Clie try { getBody().close(); } - catch (IOException ex) { - // ignore + catch (IOException ignored) { } } diff --git a/spring-web/src/testFixtures/java/org/springframework/web/testfixture/servlet/MockHttpServletRequest.java b/spring-web/src/testFixtures/java/org/springframework/web/testfixture/servlet/MockHttpServletRequest.java index 837c7c0b942..42f75d542f5 100644 --- a/spring-web/src/testFixtures/java/org/springframework/web/testfixture/servlet/MockHttpServletRequest.java +++ b/spring-web/src/testFixtures/java/org/springframework/web/testfixture/servlet/MockHttpServletRequest.java @@ -1128,8 +1128,7 @@ public class MockHttpServletRequest implements HttpServletRequest { try { return simpleDateFormat.parse(value).getTime(); } - catch (ParseException ex) { - // ignore + catch (ParseException ignored) { } } throw new IllegalArgumentException("Cannot parse date value '" + value + "' for '" + name + "' header"); diff --git a/spring-webflux/src/main/java/org/springframework/web/reactive/function/client/WebClientUtils.java b/spring-webflux/src/main/java/org/springframework/web/reactive/function/client/WebClientUtils.java index d311962f756..dfb07f5bb30 100644 --- a/spring-webflux/src/main/java/org/springframework/web/reactive/function/client/WebClientUtils.java +++ b/spring-webflux/src/main/java/org/springframework/web/reactive/function/client/WebClientUtils.java @@ -77,8 +77,7 @@ abstract class WebClientUtils { try { uri = new URI(uri.getScheme(), null, uri.getHost(), uri.getPort(), uri.getPath(), null, null); } - catch (URISyntaxException ex) { - // ignore + catch (URISyntaxException ignored) { } } return httpMethod.name() + " " + uri; diff --git a/spring-webflux/src/main/java/org/springframework/web/reactive/function/server/DefaultServerRequestBuilder.java b/spring-webflux/src/main/java/org/springframework/web/reactive/function/server/DefaultServerRequestBuilder.java index d26c440bc5f..0423d1c4404 100644 --- a/spring-webflux/src/main/java/org/springframework/web/reactive/function/server/DefaultServerRequestBuilder.java +++ b/spring-webflux/src/main/java/org/springframework/web/reactive/function/server/DefaultServerRequestBuilder.java @@ -357,8 +357,7 @@ class DefaultServerRequestBuilder implements ServerRequest.Builder { .cache(); } } - catch (InvalidMediaTypeException ex) { - // Ignore + catch (InvalidMediaTypeException ignored) { } return EMPTY_FORM_DATA; } @@ -379,8 +378,7 @@ class DefaultServerRequestBuilder implements ServerRequest.Builder { .cache(); } } - catch (InvalidMediaTypeException ex) { - // Ignore + catch (InvalidMediaTypeException ignored) { } return EMPTY_MULTIPART_DATA; } diff --git a/spring-webflux/src/main/java/org/springframework/web/reactive/resource/ResourceHandlerUtils.java b/spring-webflux/src/main/java/org/springframework/web/reactive/resource/ResourceHandlerUtils.java index 5bbb25678e3..5fab76c6f98 100644 --- a/spring-webflux/src/main/java/org/springframework/web/reactive/resource/ResourceHandlerUtils.java +++ b/spring-webflux/src/main/java/org/springframework/web/reactive/resource/ResourceHandlerUtils.java @@ -76,8 +76,7 @@ public abstract class ResourceHandlerUtils { Assert.isTrue(path.endsWith(FOLDER_SEPARATOR) || path.endsWith(WINDOWS_FOLDER_SEPARATOR), "Resource location does not end with slash: " + path); } - catch (IOException ex) { - // ignore + catch (IOException ignored) { } } diff --git a/spring-webflux/src/main/java/org/springframework/web/reactive/result/condition/ProducesRequestCondition.java b/spring-webflux/src/main/java/org/springframework/web/reactive/result/condition/ProducesRequestCondition.java index 91431651f89..22b917b1529 100644 --- a/spring-webflux/src/main/java/org/springframework/web/reactive/result/condition/ProducesRequestCondition.java +++ b/spring-webflux/src/main/java/org/springframework/web/reactive/result/condition/ProducesRequestCondition.java @@ -211,8 +211,7 @@ public final class ProducesRequestCondition extends AbstractRequestCondition