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 <vpotucek@me.com>
[brian.clozel@broadcom.com: rework commit message]
Signed-off-by: Brian Clozel <brian.clozel@broadcom.com>
This commit is contained in:
Vincent Potucek
2025-06-13 16:03:24 +02:00
committed by Brian Clozel
parent cd3ac44fb0
commit 0d4dfb6c1f
46 changed files with 66 additions and 108 deletions

View File

@@ -523,8 +523,7 @@ final class PostProcessorRegistrationDelegate {
try {
typedStringValue.resolveTargetType(this.beanFactory.getBeanClassLoader());
}
catch (ClassNotFoundException ex) {
// ignore
catch (ClassNotFoundException ignored) {
}
}

View File

@@ -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) {

View File

@@ -233,8 +233,7 @@ abstract class AbstractAopProxyTests {
try {
p2.echo(new IOException());
}
catch (IOException ex) {
catch (IOException ignored) {
}
assertThat(cta.getCalls()).isEqualTo(2);
}