diff --git a/spring-core/src/main/java/org/springframework/core/ReactiveAdapterRegistry.java b/spring-core/src/main/java/org/springframework/core/ReactiveAdapterRegistry.java index 7ae3e92fa0..0e6bfa9a93 100644 --- a/spring-core/src/main/java/org/springframework/core/ReactiveAdapterRegistry.java +++ b/spring-core/src/main/java/org/springframework/core/ReactiveAdapterRegistry.java @@ -33,10 +33,7 @@ import org.springframework.lang.Nullable; import org.springframework.util.ClassUtils; import org.springframework.util.ReflectionUtils; -import static org.springframework.core.ReactiveTypeDescriptor.multiValue; -import static org.springframework.core.ReactiveTypeDescriptor.noValue; -import static org.springframework.core.ReactiveTypeDescriptor.singleOptionalValue; -import static org.springframework.core.ReactiveTypeDescriptor.singleRequiredValue; +import static org.springframework.core.ReactiveTypeDescriptor.*; /** * A registry of adapters to adapt a Reactive Streams {@link Publisher} to/from @@ -94,11 +91,8 @@ public class ReactiveAdapterRegistry { try { new ReactorJdkFlowAdapterRegistrar().registerAdapter(this); } - catch (NoSuchMethodException ex) { - throw new IllegalStateException("Failed to find JdkFlowAdapter methods", ex); - } catch (Throwable ex) { - // Ignore + // Ignore for the time being... // We can fall back on "reactive-streams-flow-bridge" (once released) } } @@ -254,16 +248,10 @@ public class ReactiveAdapterRegistry { private static class ReactorJdkFlowAdapterRegistrar { // TODO: remove reflection when build requires JDK 9+ - - void registerAdapter(ReactiveAdapterRegistry registry) - throws NoSuchMethodException, ClassNotFoundException { - - String name = "java.util.concurrent.Flow.Publisher"; - Class type = ClassUtils.forName(name, getClass().getClassLoader()); - - Method toFlowMethod = getMethod("publisherToFlowPublisher", Publisher.class); + void registerAdapter(ReactiveAdapterRegistry registry) throws Exception { + Class type = ClassUtils.forName("java.util.concurrent.Flow.Publisher", getClass().getClassLoader()); Method toFluxMethod = getMethod("flowPublisherToFlux", type); - + Method toFlowMethod = getMethod("publisherToFlowPublisher", Publisher.class); Object emptyFlow = ReflectionUtils.invokeMethod(toFlowMethod, null, Flux.empty()); registry.registerReactiveType( diff --git a/spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/method/annotation/ServletInvocableHandlerMethod.java b/spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/method/annotation/ServletInvocableHandlerMethod.java index 483e7e4cb8..dc1206f438 100644 --- a/spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/method/annotation/ServletInvocableHandlerMethod.java +++ b/spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/method/annotation/ServletInvocableHandlerMethod.java @@ -286,13 +286,11 @@ public class ServletInvocableHandlerMethod extends InvocableHandlerMethod { @Override public boolean hasMethodAnnotation(Class annotationType) { - // Ensure @ResponseBody-style handling for values collected from a reactive type // even if actual return type is ResponseEntity> - - return ResponseBody.class.equals(annotationType) && - this.returnValue instanceof ReactiveTypeHandler.CollectedValuesList || - super.hasMethodAnnotation(annotationType); + return (super.hasMethodAnnotation(annotationType) || + (annotationType == ResponseBody.class && + this.returnValue instanceof ReactiveTypeHandler.CollectedValuesList)); } @Override