Skip to content

Commit 1b09718

Browse files
committed
Polishing
1 parent 1603c4a commit 1b09718

File tree

2 files changed

+9
-5
lines changed

2 files changed

+9
-5
lines changed

spring-messaging/src/main/java/org/springframework/messaging/handler/invocation/ReactiveReturnValueHandler.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,12 @@
2222
import org.springframework.core.ReactiveAdapter;
2323
import org.springframework.core.ReactiveAdapterRegistry;
2424
import org.springframework.messaging.support.MonoToListenableFutureAdapter;
25+
import org.springframework.util.Assert;
2526
import org.springframework.util.concurrent.ListenableFuture;
2627

2728
/**
28-
* Support for single-value reactive types (like {@code Mono} or {@code Single}) as a
29-
* return value type.
29+
* Support for single-value reactive types (like {@code Mono} or {@code Single})
30+
* as a return value type.
3031
*
3132
* @author Sebastien Deleuze
3233
* @since 5.1
@@ -53,12 +54,13 @@ public boolean supportsReturnType(MethodParameter returnType) {
5354
@Override
5455
public boolean isAsyncReturnValue(Object returnValue, MethodParameter returnType) {
5556
ReactiveAdapter adapter = this.adapterRegistry.getAdapter(returnType.getParameterType(), returnValue);
56-
return !adapter.isMultiValue() && !adapter.isNoValue();
57+
return (adapter != null && !adapter.isMultiValue() && !adapter.isNoValue());
5758
}
5859

5960
@Override
6061
public ListenableFuture<?> toListenableFuture(Object returnValue, MethodParameter returnType) {
6162
ReactiveAdapter adapter = this.adapterRegistry.getAdapter(returnType.getParameterType(), returnValue);
63+
Assert.state(adapter != null, () -> "No ReactiveAdapter found for " + returnType.getParameterType());
6264
return new MonoToListenableFutureAdapter<>(Mono.from(adapter.toPublisher(returnValue)));
6365
}
6466

spring-web/src/main/java/org/springframework/http/client/OkHttp3ClientHttpRequestFactory.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
import java.net.URI;
2222
import java.util.concurrent.TimeUnit;
2323

24+
import okhttp3.Cache;
2425
import okhttp3.OkHttpClient;
2526
import okhttp3.Request;
2627
import okhttp3.RequestBody;
@@ -118,8 +119,9 @@ public AsyncClientHttpRequest createAsyncRequest(URI uri, HttpMethod httpMethod)
118119
public void destroy() throws IOException {
119120
if (this.defaultClient) {
120121
// Clean up the client if we created it in the constructor
121-
if (this.client.cache() != null) {
122-
this.client.cache().close();
122+
Cache cache = this.client.cache();
123+
if (cache != null) {
124+
cache.close();
123125
}
124126
this.client.dispatcher().executorService().shutdown();
125127
}

0 commit comments

Comments
 (0)