From 548126ddd83d5f8cf7e7b0e9473a42db23669106 Mon Sep 17 00:00:00 2001 From: Rossen Stoyanchev Date: Wed, 21 Nov 2018 14:41:42 -0500 Subject: [PATCH] Consistently pass param info to ServerWebInputException Issue: SPR-17232 --- .../annotation/AbstractMessageReaderArgumentResolver.java | 5 +++-- .../annotation/MatrixVariableMethodArgumentResolver.java | 5 +++-- .../annotation/RequestHeaderMethodArgumentResolver.java | 4 ++-- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/spring-webflux/src/main/java/org/springframework/web/reactive/result/method/annotation/AbstractMessageReaderArgumentResolver.java b/spring-webflux/src/main/java/org/springframework/web/reactive/result/method/annotation/AbstractMessageReaderArgumentResolver.java index 9e676ad784..c6333781fc 100644 --- a/spring-webflux/src/main/java/org/springframework/web/reactive/result/method/annotation/AbstractMessageReaderArgumentResolver.java +++ b/spring-webflux/src/main/java/org/springframework/web/reactive/result/method/annotation/AbstractMessageReaderArgumentResolver.java @@ -218,8 +218,9 @@ public abstract class AbstractMessageReaderArgumentResolver extends HandlerMetho new ServerWebInputException("Failed to read HTTP message", parameter, ex) : ex); } - private ServerWebInputException handleMissingBody(MethodParameter param) { - return new ServerWebInputException("Request body is missing: " + param.getExecutable().toGenericString()); + private ServerWebInputException handleMissingBody(MethodParameter parameter) { + String paramInfo = parameter.getExecutable().toGenericString(); + return new ServerWebInputException("Request body is missing: " + paramInfo, parameter); } /** diff --git a/spring-webflux/src/main/java/org/springframework/web/reactive/result/method/annotation/MatrixVariableMethodArgumentResolver.java b/spring-webflux/src/main/java/org/springframework/web/reactive/result/method/annotation/MatrixVariableMethodArgumentResolver.java index 48248ae445..7881607bf6 100644 --- a/spring-webflux/src/main/java/org/springframework/web/reactive/result/method/annotation/MatrixVariableMethodArgumentResolver.java +++ b/spring-webflux/src/main/java/org/springframework/web/reactive/result/method/annotation/MatrixVariableMethodArgumentResolver.java @@ -120,8 +120,9 @@ public class MatrixVariableMethodArgumentResolver extends AbstractNamedValueSync @Override protected void handleMissingValue(String name, MethodParameter parameter) throws ServerWebInputException { - throw new ServerWebInputException("Missing matrix variable '" + name + - "' for method parameter of type " + parameter.getNestedParameterType().getSimpleName()); + String paramInfo = parameter.getNestedParameterType().getSimpleName(); + throw new ServerWebInputException("Missing matrix variable '" + name + "' " + + "for method parameter of type " + paramInfo, parameter); } diff --git a/spring-webflux/src/main/java/org/springframework/web/reactive/result/method/annotation/RequestHeaderMethodArgumentResolver.java b/spring-webflux/src/main/java/org/springframework/web/reactive/result/method/annotation/RequestHeaderMethodArgumentResolver.java index 4013cf6ba2..fd7dba1acf 100644 --- a/spring-webflux/src/main/java/org/springframework/web/reactive/result/method/annotation/RequestHeaderMethodArgumentResolver.java +++ b/spring-webflux/src/main/java/org/springframework/web/reactive/result/method/annotation/RequestHeaderMethodArgumentResolver.java @@ -90,8 +90,8 @@ public class RequestHeaderMethodArgumentResolver extends AbstractNamedValueSyncA @Override protected void handleMissingValue(String name, MethodParameter parameter) { String type = parameter.getNestedParameterType().getSimpleName(); - throw new ServerWebInputException("Missing request header '" + name + - "' for method parameter of type " + type); + throw new ServerWebInputException("Missing request header '" + name + "' " + + "for method parameter of type " + type, parameter); }