|
|
|
@ -170,13 +170,13 @@ public class PayloadMethodArgumentResolver implements HandlerMethodArgumentResol |
|
|
|
@SuppressWarnings("unchecked") |
|
|
|
@SuppressWarnings("unchecked") |
|
|
|
private Flux<DataBuffer> extractContent(MethodParameter parameter, Message<?> message) { |
|
|
|
private Flux<DataBuffer> extractContent(MethodParameter parameter, Message<?> message) { |
|
|
|
Object payload = message.getPayload(); |
|
|
|
Object payload = message.getPayload(); |
|
|
|
if (payload instanceof DataBuffer) { |
|
|
|
if (payload instanceof DataBuffer dataBuffer) { |
|
|
|
return Flux.just((DataBuffer) payload); |
|
|
|
return Flux.just(dataBuffer); |
|
|
|
} |
|
|
|
} |
|
|
|
if (payload instanceof Publisher) { |
|
|
|
if (payload instanceof Publisher<?> publisher) { |
|
|
|
return Flux.from((Publisher<?>) payload).map(value -> { |
|
|
|
return Flux.from(publisher).map(value -> { |
|
|
|
if (value instanceof DataBuffer) { |
|
|
|
if (value instanceof DataBuffer dataBuffer) { |
|
|
|
return (DataBuffer) value; |
|
|
|
return dataBuffer; |
|
|
|
} |
|
|
|
} |
|
|
|
String className = value.getClass().getName(); |
|
|
|
String className = value.getClass().getName(); |
|
|
|
throw getUnexpectedPayloadError(message, parameter, "Publisher<" + className + ">"); |
|
|
|
throw getUnexpectedPayloadError(message, parameter, "Publisher<" + className + ">"); |
|
|
|
@ -204,11 +204,11 @@ public class PayloadMethodArgumentResolver implements HandlerMethodArgumentResol |
|
|
|
if (headerValue == null) { |
|
|
|
if (headerValue == null) { |
|
|
|
return null; |
|
|
|
return null; |
|
|
|
} |
|
|
|
} |
|
|
|
else if (headerValue instanceof String) { |
|
|
|
else if (headerValue instanceof String stringHeader) { |
|
|
|
return MimeTypeUtils.parseMimeType((String) headerValue); |
|
|
|
return MimeTypeUtils.parseMimeType(stringHeader); |
|
|
|
} |
|
|
|
} |
|
|
|
else if (headerValue instanceof MimeType) { |
|
|
|
else if (headerValue instanceof MimeType mimeTypeHeader) { |
|
|
|
return (MimeType) headerValue; |
|
|
|
return mimeTypeHeader; |
|
|
|
} |
|
|
|
} |
|
|
|
else { |
|
|
|
else { |
|
|
|
throw new IllegalArgumentException("Unexpected MimeType value: " + headerValue); |
|
|
|
throw new IllegalArgumentException("Unexpected MimeType value: " + headerValue); |
|
|
|
@ -290,12 +290,12 @@ public class PayloadMethodArgumentResolver implements HandlerMethodArgumentResol |
|
|
|
Validated validatedAnn = AnnotationUtils.getAnnotation(ann, Validated.class); |
|
|
|
Validated validatedAnn = AnnotationUtils.getAnnotation(ann, Validated.class); |
|
|
|
if (validatedAnn != null || ann.annotationType().getSimpleName().startsWith("Valid")) { |
|
|
|
if (validatedAnn != null || ann.annotationType().getSimpleName().startsWith("Valid")) { |
|
|
|
Object hints = (validatedAnn != null ? validatedAnn.value() : AnnotationUtils.getValue(ann)); |
|
|
|
Object hints = (validatedAnn != null ? validatedAnn.value() : AnnotationUtils.getValue(ann)); |
|
|
|
Object[] validationHints = (hints instanceof Object[] ? (Object[]) hints : new Object[] {hints}); |
|
|
|
Object[] validationHints = (hints instanceof Object[] objectHint ? objectHint : new Object[] {hints}); |
|
|
|
String name = Conventions.getVariableNameForParameter(parameter); |
|
|
|
String name = Conventions.getVariableNameForParameter(parameter); |
|
|
|
return target -> { |
|
|
|
return target -> { |
|
|
|
BeanPropertyBindingResult bindingResult = new BeanPropertyBindingResult(target, name); |
|
|
|
BeanPropertyBindingResult bindingResult = new BeanPropertyBindingResult(target, name); |
|
|
|
if (!ObjectUtils.isEmpty(validationHints) && this.validator instanceof SmartValidator) { |
|
|
|
if (!ObjectUtils.isEmpty(validationHints) && this.validator instanceof SmartValidator sv) { |
|
|
|
((SmartValidator) this.validator).validate(target, bindingResult, validationHints); |
|
|
|
sv.validate(target, bindingResult, validationHints); |
|
|
|
} |
|
|
|
} |
|
|
|
else { |
|
|
|
else { |
|
|
|
this.validator.validate(target, bindingResult); |
|
|
|
this.validator.validate(target, bindingResult); |
|
|
|
|