Apply additional 'instanceof pattern matching' in spring-web
See gh-29530
This commit is contained in:
@@ -129,17 +129,18 @@ public class HandlerMethodReturnValueHandlerComposite implements AsyncHandlerMet
|
||||
@Override
|
||||
public boolean isAsyncReturnValue(Object returnValue, MethodParameter returnType) {
|
||||
HandlerMethodReturnValueHandler handler = getReturnValueHandler(returnType);
|
||||
return (handler instanceof AsyncHandlerMethodReturnValueHandler &&
|
||||
((AsyncHandlerMethodReturnValueHandler) handler).isAsyncReturnValue(returnValue, returnType));
|
||||
return (handler instanceof AsyncHandlerMethodReturnValueHandler asyncHandler &&
|
||||
asyncHandler.isAsyncReturnValue(returnValue, returnType));
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public CompletableFuture<?> toCompletableFuture(Object returnValue, MethodParameter returnType) {
|
||||
HandlerMethodReturnValueHandler handler = getReturnValueHandler(returnType);
|
||||
if (handler instanceof AsyncHandlerMethodReturnValueHandler) {
|
||||
return ((AsyncHandlerMethodReturnValueHandler) handler).toCompletableFuture(returnValue, returnType);
|
||||
if (handler instanceof AsyncHandlerMethodReturnValueHandler asyncHandler) {
|
||||
return asyncHandler.toCompletableFuture(returnValue, returnType);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2019 the original author or authors.
|
||||
* Copyright 2002-2022 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.
|
||||
@@ -343,8 +343,8 @@ class ChannelSendOperator<T> extends Mono<Void> implements Scannable {
|
||||
private void releaseCachedItem() {
|
||||
synchronized (this) {
|
||||
Object item = this.item;
|
||||
if (item instanceof DataBuffer) {
|
||||
DataBufferUtils.release((DataBuffer) item);
|
||||
if (item instanceof DataBuffer dataBuffer) {
|
||||
DataBufferUtils.release(dataBuffer);
|
||||
}
|
||||
this.item = null;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user