From 03eb6f76db2208e4283027fba338fe8da9dd755a Mon Sep 17 00:00:00 2001 From: Rossen Stoyanchev Date: Tue, 5 Sep 2017 16:11:35 -0400 Subject: [PATCH] Improve check for actual return value type Issue: SPR-15910 --- .../method/annotation/AbstractMessageWriterResultHandler.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/spring-webflux/src/main/java/org/springframework/web/reactive/result/method/annotation/AbstractMessageWriterResultHandler.java b/spring-webflux/src/main/java/org/springframework/web/reactive/result/method/annotation/AbstractMessageWriterResultHandler.java index b73523acf2..75e4f751cb 100644 --- a/spring-webflux/src/main/java/org/springframework/web/reactive/result/method/annotation/AbstractMessageWriterResultHandler.java +++ b/spring-webflux/src/main/java/org/springframework/web/reactive/result/method/annotation/AbstractMessageWriterResultHandler.java @@ -101,7 +101,8 @@ public abstract class AbstractMessageWriterResultHandler extends HandlerResultHa } else { publisher = Mono.justOrEmpty(body); - elementType = (bodyClass == null && body != null ? ResolvableType.forInstance(body) : bodyType); + elementType = ((bodyClass == null || bodyClass.equals(Object.class)) && body != null ? + ResolvableType.forInstance(body) : bodyType); } if (void.class == elementType.getRawClass() || Void.class == elementType.getRawClass()) {