Fix type check for ResponseEntity<ResponseBodyEmitter>

Issue: SPR-12693
This commit is contained in:
Rossen Stoyanchev
2015-02-05 11:16:58 -05:00
parent 13cdd22f5e
commit 8f0ddf1b1d
2 changed files with 9 additions and 8 deletions

View File

@@ -26,6 +26,7 @@ import javax.servlet.http.HttpServletResponse;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.core.MethodParameter;
import org.springframework.core.ResolvableType;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
@@ -66,14 +67,8 @@ public class ResponseBodyEmitterReturnValueHandler implements HandlerMethodRetur
return true;
}
else if (ResponseEntity.class.isAssignableFrom(returnType.getParameterType())) {
Type paramType = returnType.getGenericParameterType();
if (paramType instanceof ParameterizedType) {
ParameterizedType type = (ParameterizedType) paramType;
Type[] typeArguments = type.getActualTypeArguments();
if (typeArguments.length == 1) {
return ResponseBodyEmitter.class.isAssignableFrom((Class<?>) typeArguments[0]);
}
}
Class<?> bodyType = ResolvableType.forMethodParameter(returnType).getGeneric(0).resolve();
return (bodyType != null && ResponseBodyEmitter.class.isAssignableFrom(bodyType));
}
return false;
}