Skip to content

fix ignored exceptions #35047

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -158,8 +158,7 @@ void testRollbackRulesOnMethodPreventRollback() throws Exception {
try {
rb.echoException(new ServletException());
}
catch (ServletException ex) {

catch (ServletException ignored) {
}
assertThat(txMan.commits).as("Transaction counts match").isEqualTo(1);
}
Expand Down Expand Up @@ -272,7 +271,7 @@ public void before(Method method, Object[] args, Object target) throws Throwable
TransactionInterceptor.currentTransactionStatus();
throw new RuntimeException("Shouldn't have a transaction");
}
catch (NoTransactionException ex) {
catch (NoTransactionException ignored) {
// this is Ok
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -453,9 +453,9 @@ private ShadowMatch getTargetShadowMatch(Method method, Class<?> targetClass) {
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) {
}
}
}
Expand All @@ -478,7 +478,7 @@ private ShadowMatch getShadowMatch(Method targetMethod, Method originalMethod) {
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 {
Expand All @@ -501,7 +501,7 @@ private ShadowMatch getShadowMatch(Method targetMethod, Method originalMethod) {
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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -208,8 +208,8 @@ public static boolean isQualifierMatch(
}
}
}
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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -523,8 +523,7 @@ private void resolveTypeStringValue(TypedStringValue typedStringValue) {
try {
typedStringValue.resolveTargetType(this.beanFactory.getBeanClassLoader());
}
catch (ClassNotFoundException ex) {
// ignore
catch (ClassNotFoundException ignored) {
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -266,8 +266,8 @@ public void afterPropertiesSet() {
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
}
}

Expand Down Expand Up @@ -417,8 +417,8 @@ public <T> T unwrap(@Nullable Class<T> type) {
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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -233,8 +233,7 @@ void serializableTargetAndAdvice() throws Throwable {
try {
p2.echo(new IOException());
}
catch (IOException ex) {

catch (IOException ignored) {
}
assertThat(cta.getCalls()).isEqualTo(2);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,7 @@ protected Class<?> findClass(String name) throws ClassNotFoundException {
try (stream) {
return stream.readAllBytes();
}
catch (IOException ex) {
// ignore
catch (IOException ignored) {
}
}
return null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,8 @@ public BridgeMethodResolver(Map declToBridge, ClassLoader classLoader) {
} finally {
is.close();
}
} catch (IOException ignored) {}
} catch (IOException ignored) {
}
}
return resolved;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,8 @@ public static MethodProxy create(Class c1, Class c2, String desc, String name1,
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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -438,8 +438,7 @@ private static class KotlinDelegate {
return constructor;
}
}
catch (UnsupportedOperationException ex) {
// ignore
catch (UnsupportedOperationException ignored) {
}
return null;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -229,8 +229,7 @@ private static void close(Closeable closeable) {
try {
closeable.close();
}
catch (IOException ex) {
// ignore
catch (IOException ignored) {
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -526,8 +526,7 @@ private void resetConnection() {
try {
conn.close();
}
catch (Throwable ex) {
// ignore
catch (Throwable ignored) {
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1000,8 +1000,7 @@ private String getHost(String elementNamespace, DataHandler dataHandler) {
URI uri = ResourceUtils.toURI(elementNamespace);
return uri.getHost();
}
catch (URISyntaxException ex) {
// ignore
catch (URISyntaxException ignored) {
}
return dataHandler.getName();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -710,8 +710,7 @@ public Mono<Void> afterCompletion(int status) {
try {
return Mono.fromRunnable(() -> doAfterCompletion(status));
}
catch (Throwable ex) {
// ignore
catch (Throwable ignored) {
}

return Mono.empty();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,7 @@ public void close() {
try {
getBody().close();
}
catch (IOException ex) {
// ignore
catch (IOException ignored) {
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1129,8 +1129,7 @@ private long parseDateHeader(String name, String value) {
try {
return simpleDateFormat.parse(value).getTime();
}
catch (ParseException ex) {
// ignore
catch (ParseException ignored) {
}
}
throw new IllegalArgumentException("Cannot parse date value '" + value + "' for '" + name + "' header");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1223,8 +1223,7 @@ public void setHost(@Nullable InetSocketAddress host) {
try {
port = Integer.parseInt(portString);
}
catch (NumberFormatException ex) {
// ignore
catch (NumberFormatException ignored) {
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,7 @@ public void close() {
this.httpResponse.close();
}
}
catch (IOException ex) {
// Ignore exception on close...
catch (IOException ignored) {
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,8 +108,7 @@ public void close() {
StreamUtils.drain(body);
body.close();
}
catch (IOException ex) {
// ignore
catch (IOException ignored) {
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,8 +119,7 @@ else if (expiresAttribute != null) {
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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -158,20 +158,20 @@ protected void writeContent(Resource resource, HttpOutputMessage outputMessage)
in.transferTo(out);
out.flush();
}
catch (NullPointerException ex) {
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

image

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thats why its important to have empty blocks inline.

Copy link
Author

@Pankraz76 Pankraz76 Jun 13, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

as this so important should give this special attention then. @bclozel

its not about the close as thats the same but about the catch as this seems to differ.

// ignore, see SPR-13620
catch (NullPointerException ignored) {
// see SPR-13620
}
finally {
try {
in.close();
}
catch (Throwable ex) {
// ignore, see SPR-12999
catch (Throwable ignored) {
// see SPR-12999
}
}
}
catch (FileNotFoundException ex) {
// ignore, see SPR-12999
catch (FileNotFoundException ignored) {
// see SPR-12999
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -183,8 +183,7 @@ protected void writeResourceRegion(ResourceRegion region, HttpOutputMessage outp
try {
in.close();
}
catch (IOException ex) {
// ignore
catch (IOException ignored) {
}
}
}
Expand Down Expand Up @@ -244,8 +243,7 @@ private void writeResourceRegionCollection(Collection<ResourceRegion> resourceRe
in.close();
}
}
catch (IOException ex) {
// ignore
catch (IOException ignored) {
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -270,8 +270,7 @@ private StreamSource readStreamSource(InputStream body) throws IOException {
transform(t, new StreamResult(os));
return os.count;
}
catch (TransformerException ex) {
// ignore
catch (TransformerException ignored) {
}
}
return null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -439,8 +439,7 @@ public <T> void onNext(AbstractListenerWriteProcessor<T> processor, T data) {
// ignore
}
@Override
public <T> void onError(AbstractListenerWriteProcessor<T> processor, Throwable ex) {
// ignore
public <T> void onError(AbstractListenerWriteProcessor<T> processor, Throwable ignored) {
}
@Override
public <T> void onComplete(AbstractListenerWriteProcessor<T> processor) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -309,26 +309,23 @@ private static void delegateTimeout(AsyncListener listener, AsyncEvent event) {
try {
listener.onTimeout(event);
}
catch (Exception ex) {
// Ignore
catch (Exception ignored) {
}
}

private static void delegateError(AsyncListener listener, AsyncEvent event) {
try {
listener.onError(event);
}
catch (Exception ex) {
// Ignore
catch (Exception ignored) {
}
}

private static void delegateComplete(AsyncListener listener, AsyncEvent event) {
try {
listener.onComplete(event);
}
catch (Exception ex) {
// Ignore
catch (Exception ignored) {
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -152,8 +152,7 @@ private static byte[] getResponseBody(ClientHttpResponse response) {
try {
return FileCopyUtils.copyToByteArray(response.getBody());
}
catch (IOException ex) {
// ignore
catch (IOException ignored) {
}
return new byte[0];
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,8 +113,7 @@ private void cancelTask() {
try {
future.cancel(true);
}
catch (Throwable ex) {
// Ignore
catch (Throwable ignored) {
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -235,8 +235,7 @@ private int tryObtainLock() {
break;
}
}
catch (InterruptedException ex) {
// ignore
catch (InterruptedException ignored) {
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,8 +122,7 @@ public boolean isReadable() {
try {
is.close();
}
catch (IOException ex) {
// ignore
catch (IOException ignored) {
}
return true;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -151,8 +151,7 @@ private static void addGroupAdapter(
Class<?> clazz = ClassUtils.forName(className, HttpServiceGroupAdapter.class.getClassLoader());
groupAdapters.put(clientType, (HttpServiceGroupAdapter<?>) BeanUtils.instantiateClass(clazz));
}
catch (ClassNotFoundException ex) {
// ignore
catch (ClassNotFoundException ignored) {
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ void requestContextListenerWithDifferentThread() {
try {
thread.join();
}
catch (InterruptedException ex) {
catch (InterruptedException ignored) {
}
// Still bound to original thread, but at least completed.
assertThat(RequestContextHolder.getRequestAttributes()).isNotNull();
Expand Down
Loading