Skip to content

Commit 79bc227

Browse files
committed
Remove SimpleResultHandler
There is really no need for a result handler dedicated to a void return value and it's actually problematic to have it. Each result handler treats void as necessary. For an @responsebody method it means an empty body. For view resolution it means no specific value was returned and we should procede with selecting a default view name. Having a dedicated void result handler can interfere with this especially since view resolution needs to be last in order. At the same time there are cases when no result handling is needed and the response is fully handled within the HandlerAdapter. This is the case with WebHandler and the SimpleHandlerAdapter. For that case we simply return mono.then(aVoid -> Mono.empty()) which effectively returns an empty Mono and no result handling follows. The HandlerAdapter already says you can return no values at all if the response is fully handled.
1 parent 328e04f commit 79bc227

File tree

5 files changed

+1
-219
lines changed

5 files changed

+1
-219
lines changed

spring-web-reactive/src/main/java/org/springframework/web/reactive/config/WebReactiveConfiguration.java

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,6 @@
5555
import org.springframework.web.reactive.accept.RequestedContentTypeResolver;
5656
import org.springframework.web.reactive.accept.RequestedContentTypeResolverBuilder;
5757
import org.springframework.web.reactive.result.SimpleHandlerAdapter;
58-
import org.springframework.web.reactive.result.SimpleResultHandler;
5958
import org.springframework.web.reactive.result.method.HandlerMethodArgumentResolver;
6059
import org.springframework.web.reactive.result.method.annotation.RequestMappingHandlerAdapter;
6160
import org.springframework.web.reactive.result.method.annotation.RequestMappingHandlerMapping;
@@ -321,11 +320,6 @@ public SimpleHandlerAdapter simpleHandlerAdapter() {
321320
return new SimpleHandlerAdapter();
322321
}
323322

324-
@Bean
325-
public SimpleResultHandler simpleResultHandler() {
326-
return new SimpleResultHandler();
327-
}
328-
329323
@Bean
330324
public ResponseEntityResultHandler responseEntityResultHandler() {
331325
return new ResponseEntityResultHandler(getMessageWriters(), mvcContentTypeResolver());

spring-web-reactive/src/main/java/org/springframework/web/reactive/result/SimpleHandlerAdapter.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ public boolean supports(Object handler) {
6060
public Mono<HandlerResult> handle(ServerWebExchange exchange, Object handler) {
6161
WebHandler webHandler = (WebHandler) handler;
6262
Mono<Void> mono = webHandler.handle(exchange);
63-
return Mono.just(new HandlerResult(webHandler, mono, RETURN_TYPE));
63+
return mono.then(aVoid -> Mono.empty());
6464
}
6565

6666
}

spring-web-reactive/src/main/java/org/springframework/web/reactive/result/SimpleResultHandler.java

Lines changed: 0 additions & 112 deletions
This file was deleted.

spring-web-reactive/src/test/java/org/springframework/web/reactive/result/SimpleResultHandlerTests.java

Lines changed: 0 additions & 95 deletions
This file was deleted.

spring-web-reactive/src/test/java/org/springframework/web/reactive/result/SimpleUrlHandlerMappingIntegrationTests.java

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -143,11 +143,6 @@ public SimpleUrlHandlerMapping handlerMapping() {
143143
public SimpleHandlerAdapter handlerAdapter() {
144144
return new SimpleHandlerAdapter();
145145
}
146-
147-
@Bean
148-
public SimpleResultHandler resultHandler() {
149-
return new SimpleResultHandler();
150-
}
151146
}
152147

153148
}

0 commit comments

Comments
 (0)