Streamline ReactiveAdapterRegistry.getAdapter usage
Closes gh-22842
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2018 the original author or authors.
|
||||
* Copyright 2002-2019 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.
|
||||
@@ -76,14 +76,14 @@ class ReactiveTypeHandler {
|
||||
|
||||
private static Log logger = LogFactory.getLog(ReactiveTypeHandler.class);
|
||||
|
||||
private final ReactiveAdapterRegistry reactiveRegistry;
|
||||
private final ReactiveAdapterRegistry adapterRegistry;
|
||||
|
||||
private final TaskExecutor taskExecutor;
|
||||
|
||||
private Boolean taskExecutorWarning;
|
||||
|
||||
private final ContentNegotiationManager contentNegotiationManager;
|
||||
|
||||
private boolean taskExecutorWarning;
|
||||
|
||||
|
||||
public ReactiveTypeHandler() {
|
||||
this(ReactiveAdapterRegistry.getSharedInstance(), new SyncTaskExecutor(), new ContentNegotiationManager());
|
||||
@@ -93,10 +93,12 @@ class ReactiveTypeHandler {
|
||||
Assert.notNull(registry, "ReactiveAdapterRegistry is required");
|
||||
Assert.notNull(executor, "TaskExecutor is required");
|
||||
Assert.notNull(manager, "ContentNegotiationManager is required");
|
||||
this.reactiveRegistry = registry;
|
||||
this.adapterRegistry = registry;
|
||||
this.taskExecutor = executor;
|
||||
this.taskExecutorWarning = executor instanceof SimpleAsyncTaskExecutor || executor instanceof SyncTaskExecutor;
|
||||
this.contentNegotiationManager = manager;
|
||||
|
||||
this.taskExecutorWarning =
|
||||
(executor instanceof SimpleAsyncTaskExecutor || executor instanceof SyncTaskExecutor);
|
||||
}
|
||||
|
||||
|
||||
@@ -104,7 +106,7 @@ class ReactiveTypeHandler {
|
||||
* Whether the type can be adapted to a Reactive Streams {@link Publisher}.
|
||||
*/
|
||||
public boolean isReactiveType(Class<?> type) {
|
||||
return (this.reactiveRegistry.hasAdapters() && this.reactiveRegistry.getAdapter(type) != null);
|
||||
return (this.adapterRegistry.getAdapter(type) != null);
|
||||
}
|
||||
|
||||
|
||||
@@ -119,7 +121,7 @@ class ReactiveTypeHandler {
|
||||
ModelAndViewContainer mav, NativeWebRequest request) throws Exception {
|
||||
|
||||
Assert.notNull(returnValue, "Expected return value");
|
||||
ReactiveAdapter adapter = this.reactiveRegistry.getAdapter(returnValue.getClass());
|
||||
ReactiveAdapter adapter = this.adapterRegistry.getAdapter(returnValue.getClass());
|
||||
Assert.state(adapter != null, () -> "Unexpected return value: " + returnValue);
|
||||
|
||||
ResolvableType elementType = ResolvableType.forMethodParameter(returnType).getGeneric();
|
||||
|
||||
Reference in New Issue
Block a user