From c4a95c99e55ad8d555ca3e1fd51fda135c5adf1e Mon Sep 17 00:00:00 2001 From: Juergen Hoeller Date: Wed, 8 May 2019 18:19:19 +0200 Subject: [PATCH 1/2] Upgrade to Reactor Californium SR7 --- build.gradle | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/build.gradle b/build.gradle index 0ab8c2d6df..9efec23394 100644 --- a/build.gradle +++ b/build.gradle @@ -38,7 +38,7 @@ ext { kotlinVersion = "1.2.71" log4jVersion = "2.11.2" nettyVersion = "4.1.36.Final" - reactorVersion = "Californium-BUILD-SNAPSHOT" + reactorVersion = "Californium-SR7" rxjavaVersion = "1.3.8" rxjavaAdapterVersion = "1.2.1" rxjava2Version = "2.2.8" @@ -149,7 +149,6 @@ configure(allprojects) { project -> repositories { maven { url "https://repo.spring.io/libs-release" } - maven { url "https://repo.spring.io/snapshot" } // Reactor mavenLocal() } From 190b751147c34bcda822f8a63f97fd45f9d9aa3b Mon Sep 17 00:00:00 2001 From: Juergen Hoeller Date: Thu, 9 May 2019 02:09:31 +0200 Subject: [PATCH 2/2] Support any HttpEntity implementing ResolvableTypeProvider Closes gh-22931 --- .../http/client/MultipartBodyBuilder.java | 14 +++++++++----- .../multipart/MultipartHttpMessageWriter.java | 9 +++------ 2 files changed, 12 insertions(+), 11 deletions(-) diff --git a/spring-web/src/main/java/org/springframework/http/client/MultipartBodyBuilder.java b/spring-web/src/main/java/org/springframework/http/client/MultipartBodyBuilder.java index c1f600b1c0..1e42dc2459 100644 --- a/spring-web/src/main/java/org/springframework/http/client/MultipartBodyBuilder.java +++ b/spring-web/src/main/java/org/springframework/http/client/MultipartBodyBuilder.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2018 the original author or authors. + * Copyright 2002-2019 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -25,9 +25,11 @@ import org.reactivestreams.Publisher; import org.springframework.core.ParameterizedTypeReference; import org.springframework.core.ResolvableType; +import org.springframework.core.ResolvableTypeProvider; import org.springframework.http.HttpEntity; import org.springframework.http.HttpHeaders; import org.springframework.http.MediaType; +import org.springframework.lang.NonNull; import org.springframework.lang.Nullable; import org.springframework.util.Assert; import org.springframework.util.LinkedMultiValueMap; @@ -263,13 +265,13 @@ public final class MultipartBodyBuilder { * @param the type contained in the publisher * @param

the publisher */ - public static final class PublisherEntity> extends HttpEntity

{ + public static final class PublisherEntity> extends HttpEntity

+ implements ResolvableTypeProvider { private final ResolvableType resolvableType; - - private PublisherEntity(@Nullable MultiValueMap headers, P publisher, - ResolvableType resolvableType) { + PublisherEntity( + @Nullable MultiValueMap headers, P publisher, ResolvableType resolvableType) { super(publisher, headers); Assert.notNull(publisher, "'publisher' must not be null"); @@ -280,6 +282,8 @@ public final class MultipartBodyBuilder { /** * Return the element type for the {@code Publisher} body. */ + @Override + @NonNull public ResolvableType getResolvableType() { return this.resolvableType; } diff --git a/spring-web/src/main/java/org/springframework/http/codec/multipart/MultipartHttpMessageWriter.java b/spring-web/src/main/java/org/springframework/http/codec/multipart/MultipartHttpMessageWriter.java index 1118b808b5..80f21cfa8b 100644 --- a/spring-web/src/main/java/org/springframework/http/codec/multipart/MultipartHttpMessageWriter.java +++ b/spring-web/src/main/java/org/springframework/http/codec/multipart/MultipartHttpMessageWriter.java @@ -34,6 +34,7 @@ import reactor.core.publisher.Flux; import reactor.core.publisher.Mono; import org.springframework.core.ResolvableType; +import org.springframework.core.ResolvableTypeProvider; import org.springframework.core.codec.CharSequenceEncoder; import org.springframework.core.codec.CodecException; import org.springframework.core.codec.Hints; @@ -46,7 +47,6 @@ import org.springframework.http.HttpEntity; import org.springframework.http.HttpHeaders; import org.springframework.http.MediaType; import org.springframework.http.ReactiveHttpOutputMessage; -import org.springframework.http.client.MultipartBodyBuilder; import org.springframework.http.codec.EncoderHttpMessageWriter; import org.springframework.http.codec.FormHttpMessageWriter; import org.springframework.http.codec.HttpMessageWriter; @@ -265,11 +265,8 @@ public class MultipartHttpMessageWriter extends LoggingCodecSupport outputHeaders.putAll(httpEntity.getHeaders()); body = httpEntity.getBody(); Assert.state(body != null, "MultipartHttpMessageWriter only supports HttpEntity with body"); - - if (httpEntity instanceof MultipartBodyBuilder.PublisherEntity) { - MultipartBodyBuilder.PublisherEntity publisherEntity = - (MultipartBodyBuilder.PublisherEntity) httpEntity; - resolvableType = publisherEntity.getResolvableType(); + if (httpEntity instanceof ResolvableTypeProvider) { + resolvableType = ((ResolvableTypeProvider) httpEntity).getResolvableType(); } } else {