From ee804ee8fb2ca5ddd446460f87193489f86cd211 Mon Sep 17 00:00:00 2001 From: Juergen Hoeller Date: Fri, 4 Apr 2025 00:22:24 +0200 Subject: [PATCH] Avoid throwing of plain RuntimeException --- .../context/aot/AbstractAotProcessor.java | 5 +++-- .../annotation/ScheduledAnnotationReactiveSupport.java | 10 +++++----- .../test/web/servlet/setup/AbstractMockMvcBuilder.java | 4 ++-- .../org/springframework/web/servlet/SmartView.java | 3 +-- .../ResponseBodyEmitterReturnValueHandler.java | 4 ++-- 5 files changed, 13 insertions(+), 13 deletions(-) diff --git a/spring-context/src/main/java/org/springframework/context/aot/AbstractAotProcessor.java b/spring-context/src/main/java/org/springframework/context/aot/AbstractAotProcessor.java index 58c63fc117e..913cece9d08 100644 --- a/spring-context/src/main/java/org/springframework/context/aot/AbstractAotProcessor.java +++ b/spring-context/src/main/java/org/springframework/context/aot/AbstractAotProcessor.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2024 the original author or authors. + * Copyright 2002-2025 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -17,6 +17,7 @@ package org.springframework.context.aot; import java.io.IOException; +import java.io.UncheckedIOException; import java.nio.file.Path; import org.springframework.aot.generate.FileSystemGeneratedFiles; @@ -102,7 +103,7 @@ public abstract class AbstractAotProcessor { FileSystemUtils.deleteRecursively(path); } catch (IOException ex) { - throw new RuntimeException("Failed to delete existing output in '" + path + "'"); + throw new UncheckedIOException("Failed to delete existing output in '" + path + "'", ex); } } } diff --git a/spring-context/src/main/java/org/springframework/scheduling/annotation/ScheduledAnnotationReactiveSupport.java b/spring-context/src/main/java/org/springframework/scheduling/annotation/ScheduledAnnotationReactiveSupport.java index a51af6a215e..c6d6c37b40d 100644 --- a/spring-context/src/main/java/org/springframework/scheduling/annotation/ScheduledAnnotationReactiveSupport.java +++ b/spring-context/src/main/java/org/springframework/scheduling/annotation/ScheduledAnnotationReactiveSupport.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2024 the original author or authors. + * Copyright 2002-2025 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -205,9 +205,9 @@ abstract class ScheduledAnnotationReactiveSupport { final Supplier contextSupplier; SubscribingRunnable(Publisher publisher, boolean shouldBlock, - @Nullable String qualifier, List subscriptionTrackerRegistry, - String displayName, Supplier observationRegistrySupplier, - Supplier contextSupplier) { + @Nullable String qualifier, List subscriptionTrackerRegistry, + String displayName, Supplier observationRegistrySupplier, + Supplier contextSupplier) { this.publisher = publisher; this.shouldBlock = shouldBlock; @@ -236,7 +236,7 @@ abstract class ScheduledAnnotationReactiveSupport { latch.await(); } catch (InterruptedException ex) { - throw new RuntimeException(ex); + Thread.currentThread().interrupt(); } } else { diff --git a/spring-test/src/main/java/org/springframework/test/web/servlet/setup/AbstractMockMvcBuilder.java b/spring-test/src/main/java/org/springframework/test/web/servlet/setup/AbstractMockMvcBuilder.java index 1180d5a4a42..c057cde43fe 100644 --- a/spring-test/src/main/java/org/springframework/test/web/servlet/setup/AbstractMockMvcBuilder.java +++ b/spring-test/src/main/java/org/springframework/test/web/servlet/setup/AbstractMockMvcBuilder.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2023 the original author or authors. + * Copyright 2002-2025 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -191,7 +191,7 @@ public abstract class AbstractMockMvcBuilder filterDecorator.initIfRequired(servletContext); } catch (ServletException ex) { - throw new RuntimeException("Failed to initialize Filter " + filter, ex); + throw new IllegalStateException("Failed to initialize Filter " + filter, ex); } } } diff --git a/spring-webmvc/src/main/java/org/springframework/web/servlet/SmartView.java b/spring-webmvc/src/main/java/org/springframework/web/servlet/SmartView.java index 5bfa9ed2fa1..5cf8250aef9 100644 --- a/spring-webmvc/src/main/java/org/springframework/web/servlet/SmartView.java +++ b/spring-webmvc/src/main/java/org/springframework/web/servlet/SmartView.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2024 the original author or authors. + * Copyright 2002-2025 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -27,7 +27,6 @@ import java.util.Locale; */ public interface SmartView extends View { - /** * Whether the view performs a redirect. */ diff --git a/spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/method/annotation/ResponseBodyEmitterReturnValueHandler.java b/spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/method/annotation/ResponseBodyEmitterReturnValueHandler.java index 288f644ae96..26cc1e8811d 100644 --- a/spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/method/annotation/ResponseBodyEmitterReturnValueHandler.java +++ b/spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/method/annotation/ResponseBodyEmitterReturnValueHandler.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2024 the original author or authors. + * Copyright 2002-2025 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -404,7 +404,7 @@ public class ResponseBodyEmitterReturnValueHandler implements HandlerMethodRetur throw ex; } catch (Exception ex) { - throw new RuntimeException("Failed to render " + modelAndView, ex); + throw new IllegalStateException("Failed to render " + modelAndView, ex); } finally { RequestContextHolder.resetRequestAttributes();