Browse Source

Avoid throwing of plain RuntimeException

pull/34732/head
Juergen Hoeller 9 months ago
parent
commit
ee804ee8fb
  1. 5
      spring-context/src/main/java/org/springframework/context/aot/AbstractAotProcessor.java
  2. 10
      spring-context/src/main/java/org/springframework/scheduling/annotation/ScheduledAnnotationReactiveSupport.java
  3. 4
      spring-test/src/main/java/org/springframework/test/web/servlet/setup/AbstractMockMvcBuilder.java
  4. 3
      spring-webmvc/src/main/java/org/springframework/web/servlet/SmartView.java
  5. 4
      spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/method/annotation/ResponseBodyEmitterReturnValueHandler.java

5
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"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -17,6 +17,7 @@
package org.springframework.context.aot; package org.springframework.context.aot;
import java.io.IOException; import java.io.IOException;
import java.io.UncheckedIOException;
import java.nio.file.Path; import java.nio.file.Path;
import org.springframework.aot.generate.FileSystemGeneratedFiles; import org.springframework.aot.generate.FileSystemGeneratedFiles;
@ -102,7 +103,7 @@ public abstract class AbstractAotProcessor<T> {
FileSystemUtils.deleteRecursively(path); FileSystemUtils.deleteRecursively(path);
} }
catch (IOException ex) { catch (IOException ex) {
throw new RuntimeException("Failed to delete existing output in '" + path + "'"); throw new UncheckedIOException("Failed to delete existing output in '" + path + "'", ex);
} }
} }
} }

10
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"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -205,9 +205,9 @@ abstract class ScheduledAnnotationReactiveSupport {
final Supplier<ScheduledTaskObservationContext> contextSupplier; final Supplier<ScheduledTaskObservationContext> contextSupplier;
SubscribingRunnable(Publisher<?> publisher, boolean shouldBlock, SubscribingRunnable(Publisher<?> publisher, boolean shouldBlock,
@Nullable String qualifier, List<Runnable> subscriptionTrackerRegistry, @Nullable String qualifier, List<Runnable> subscriptionTrackerRegistry,
String displayName, Supplier<ObservationRegistry> observationRegistrySupplier, String displayName, Supplier<ObservationRegistry> observationRegistrySupplier,
Supplier<ScheduledTaskObservationContext> contextSupplier) { Supplier<ScheduledTaskObservationContext> contextSupplier) {
this.publisher = publisher; this.publisher = publisher;
this.shouldBlock = shouldBlock; this.shouldBlock = shouldBlock;
@ -236,7 +236,7 @@ abstract class ScheduledAnnotationReactiveSupport {
latch.await(); latch.await();
} }
catch (InterruptedException ex) { catch (InterruptedException ex) {
throw new RuntimeException(ex); Thread.currentThread().interrupt();
} }
} }
else { else {

4
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"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -191,7 +191,7 @@ public abstract class AbstractMockMvcBuilder<B extends AbstractMockMvcBuilder<B>
filterDecorator.initIfRequired(servletContext); filterDecorator.initIfRequired(servletContext);
} }
catch (ServletException ex) { catch (ServletException ex) {
throw new RuntimeException("Failed to initialize Filter " + filter, ex); throw new IllegalStateException("Failed to initialize Filter " + filter, ex);
} }
} }
} }

3
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"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with 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 { public interface SmartView extends View {
/** /**
* Whether the view performs a redirect. * Whether the view performs a redirect.
*/ */

4
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"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with 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; throw ex;
} }
catch (Exception ex) { catch (Exception ex) {
throw new RuntimeException("Failed to render " + modelAndView, ex); throw new IllegalStateException("Failed to render " + modelAndView, ex);
} }
finally { finally {
RequestContextHolder.resetRequestAttributes(); RequestContextHolder.resetRequestAttributes();

Loading…
Cancel
Save