From b5bce1f0178d94701021c4872feac7bcfa1b5a38 Mon Sep 17 00:00:00 2001 From: Brian Clozel Date: Fri, 8 Jul 2016 12:00:06 +0200 Subject: [PATCH] Update after `reactor.core.converter.Converters` changes Reactor's `DependencyUtils` has been renamed to `Converters` and all the `from` converter methods have been disambiguated to `fromPublisher`, `toPublisher`. --- .../convert/support/ReactorToRxJava1Converter.java | 12 ++++++------ .../client/reactive/RxNettyClientHttpRequest.java | 6 +++--- .../client/reactive/RxNettyClientHttpResponse.java | 2 +- .../server/reactive/RxNettyHttpHandlerAdapter.java | 2 +- .../server/reactive/RxNettyServerHttpRequest.java | 2 +- .../server/reactive/RxNettyServerHttpResponse.java | 4 ++-- .../reactive/RxJava1WebResponseExtractors.java | 12 ++++++------ .../reactive/config/WebReactiveConfiguration.java | 4 ++-- .../annotation/HttpEntityArgumentResolverTests.java | 4 ++-- .../annotation/RequestBodyArgumentResolverTests.java | 8 ++++---- 10 files changed, 28 insertions(+), 28 deletions(-) diff --git a/spring-web-reactive/src/main/java/org/springframework/core/convert/support/ReactorToRxJava1Converter.java b/spring-web-reactive/src/main/java/org/springframework/core/convert/support/ReactorToRxJava1Converter.java index 67c66bae9d..42b9d9d809 100644 --- a/spring-web-reactive/src/main/java/org/springframework/core/convert/support/ReactorToRxJava1Converter.java +++ b/spring-web-reactive/src/main/java/org/springframework/core/convert/support/ReactorToRxJava1Converter.java @@ -56,22 +56,22 @@ public final class ReactorToRxJava1Converter implements GenericConverter { return null; } if (Observable.class.isAssignableFrom(sourceType.getType())) { - return RxJava1ObservableConverter.from((Observable) source); + return RxJava1ObservableConverter.toPublisher((Observable) source); } else if (Observable.class.isAssignableFrom(targetType.getType())) { - return RxJava1ObservableConverter.from((Publisher) source); + return RxJava1ObservableConverter.fromPublisher((Publisher) source); } else if (Single.class.isAssignableFrom(sourceType.getType())) { - return RxJava1SingleConverter.from((Single) source); + return RxJava1SingleConverter.toPublisher((Single) source); } else if (Single.class.isAssignableFrom(targetType.getType())) { - return RxJava1SingleConverter.from((Publisher) source); + return RxJava1SingleConverter.fromPublisher((Publisher) source); } else if (Completable.class.isAssignableFrom(sourceType.getType())) { - return RxJava1CompletableConverter.from((Completable) source); + return RxJava1CompletableConverter.toPublisher((Completable) source); } else if (Completable.class.isAssignableFrom(targetType.getType())) { - return RxJava1CompletableConverter.from((Publisher) source); + return RxJava1CompletableConverter.fromPublisher((Publisher) source); } return null; } diff --git a/spring-web-reactive/src/main/java/org/springframework/http/client/reactive/RxNettyClientHttpRequest.java b/spring-web-reactive/src/main/java/org/springframework/http/client/reactive/RxNettyClientHttpRequest.java index e0804c07a8..8d3dbcd8ac 100644 --- a/spring-web-reactive/src/main/java/org/springframework/http/client/reactive/RxNettyClientHttpRequest.java +++ b/spring-web-reactive/src/main/java/org/springframework/http/client/reactive/RxNettyClientHttpRequest.java @@ -79,7 +79,7 @@ public class RxNettyClientHttpRequest extends AbstractClientHttpRequest { @Override public Mono writeWith(Publisher body) { - this.body = RxJava1ObservableConverter.from(Flux.from(body) + this.body = RxJava1ObservableConverter.fromPublisher(Flux.from(body) .map(b -> dataBufferFactory.wrap(b.asByteBuffer()).getNativeBuffer())); return Mono.empty(); @@ -119,10 +119,10 @@ public class RxNettyClientHttpRequest extends AbstractClientHttpRequest { }) .map(req -> { if (this.body != null) { - return RxJava1ObservableConverter.from(req.writeContent(this.body)); + return RxJava1ObservableConverter.toPublisher(req.writeContent(this.body)); } else { - return RxJava1ObservableConverter.from(req); + return RxJava1ObservableConverter.toPublisher(req); } }) .flatMap(resp -> resp) diff --git a/spring-web-reactive/src/main/java/org/springframework/http/client/reactive/RxNettyClientHttpResponse.java b/spring-web-reactive/src/main/java/org/springframework/http/client/reactive/RxNettyClientHttpResponse.java index 4495d134f5..af25af009b 100644 --- a/spring-web-reactive/src/main/java/org/springframework/http/client/reactive/RxNettyClientHttpResponse.java +++ b/spring-web-reactive/src/main/java/org/springframework/http/client/reactive/RxNettyClientHttpResponse.java @@ -85,7 +85,7 @@ public class RxNettyClientHttpResponse implements ClientHttpResponse { @Override public Flux getBody() { return RxJava1ObservableConverter - .from(this.response.getContent().map(dataBufferFactory::wrap)); + .toPublisher(this.response.getContent().map(dataBufferFactory::wrap)); } @Override diff --git a/spring-web-reactive/src/main/java/org/springframework/http/server/reactive/RxNettyHttpHandlerAdapter.java b/spring-web-reactive/src/main/java/org/springframework/http/server/reactive/RxNettyHttpHandlerAdapter.java index 6d0b8cb720..4d7cc5a69c 100644 --- a/spring-web-reactive/src/main/java/org/springframework/http/server/reactive/RxNettyHttpHandlerAdapter.java +++ b/spring-web-reactive/src/main/java/org/springframework/http/server/reactive/RxNettyHttpHandlerAdapter.java @@ -49,7 +49,7 @@ public class RxNettyHttpHandlerAdapter implements RequestHandler result = this.httpHandler.handle(adaptedRequest, adaptedResponse); - return RxJava1ObservableConverter.from(result); + return RxJava1ObservableConverter.fromPublisher(result); } } diff --git a/spring-web-reactive/src/main/java/org/springframework/http/server/reactive/RxNettyServerHttpRequest.java b/spring-web-reactive/src/main/java/org/springframework/http/server/reactive/RxNettyServerHttpRequest.java index fd5a5de1ef..4d77f6b484 100644 --- a/spring-web-reactive/src/main/java/org/springframework/http/server/reactive/RxNettyServerHttpRequest.java +++ b/spring-web-reactive/src/main/java/org/springframework/http/server/reactive/RxNettyServerHttpRequest.java @@ -94,7 +94,7 @@ public class RxNettyServerHttpRequest extends AbstractServerHttpRequest { @Override public Flux getBody() { Observable content = this.request.getContent().map(dataBufferFactory::wrap); - return RxJava1ObservableConverter.from(content); + return RxJava1ObservableConverter.toPublisher(content); } } diff --git a/spring-web-reactive/src/main/java/org/springframework/http/server/reactive/RxNettyServerHttpResponse.java b/spring-web-reactive/src/main/java/org/springframework/http/server/reactive/RxNettyServerHttpResponse.java index 9d50f4d337..db90248a12 100644 --- a/spring-web-reactive/src/main/java/org/springframework/http/server/reactive/RxNettyServerHttpResponse.java +++ b/spring-web-reactive/src/main/java/org/springframework/http/server/reactive/RxNettyServerHttpResponse.java @@ -71,8 +71,8 @@ public class RxNettyServerHttpResponse extends AbstractServerHttpResponse { @Override protected Mono writeWithInternal(Publisher body) { - Observable content = RxJava1ObservableConverter.from(body).map(this::toByteBuf); - return RxJava1ObservableConverter.from(this.response.write(content, bb -> bb instanceof FlushingByteBuf)).then(); + Observable content = RxJava1ObservableConverter.fromPublisher(body).map(this::toByteBuf); + return RxJava1ObservableConverter.toPublisher(this.response.write(content, bb -> bb instanceof FlushingByteBuf)).then(); } private ByteBuf toByteBuf(DataBuffer buffer) { diff --git a/spring-web-reactive/src/main/java/org/springframework/web/client/reactive/RxJava1WebResponseExtractors.java b/spring-web-reactive/src/main/java/org/springframework/web/client/reactive/RxJava1WebResponseExtractors.java index 0eb51c70d8..03e1bd9258 100644 --- a/spring-web-reactive/src/main/java/org/springframework/web/client/reactive/RxJava1WebResponseExtractors.java +++ b/spring-web-reactive/src/main/java/org/springframework/web/client/reactive/RxJava1WebResponseExtractors.java @@ -53,7 +53,7 @@ public class RxJava1WebResponseExtractors { ResolvableType resolvableType = ResolvableType.forClass(sourceClass); //noinspection unchecked - return webResponse -> (Single) RxJava1SingleConverter.from(webResponse.getClientResponse() + return webResponse -> (Single) RxJava1SingleConverter.fromPublisher(webResponse.getClientResponse() .flatMap(resp -> decodeResponseBody(resp, resolvableType, webResponse.getMessageDecoders())) .next()); } @@ -64,7 +64,7 @@ public class RxJava1WebResponseExtractors { public static WebResponseExtractor> bodyStream(Class sourceClass) { ResolvableType resolvableType = ResolvableType.forClass(sourceClass); - return webResponse -> RxJava1ObservableConverter.from(webResponse.getClientResponse() + return webResponse -> RxJava1ObservableConverter.fromPublisher(webResponse.getClientResponse() .flatMap(resp -> decodeResponseBody(resp, resolvableType, webResponse.getMessageDecoders()))); } @@ -76,7 +76,7 @@ public class RxJava1WebResponseExtractors { ResolvableType resolvableType = ResolvableType.forClass(sourceClass); return webResponse -> (Single>) - RxJava1SingleConverter.from(webResponse.getClientResponse() + RxJava1SingleConverter.fromPublisher(webResponse.getClientResponse() .then(response -> Mono.when( decodeResponseBody(response, resolvableType, webResponse.getMessageDecoders()).next(), @@ -94,10 +94,10 @@ public class RxJava1WebResponseExtractors { */ public static WebResponseExtractor>>> responseStream(Class sourceClass) { ResolvableType resolvableType = ResolvableType.forClass(sourceClass); - return webResponse -> RxJava1SingleConverter.from(webResponse.getClientResponse() + return webResponse -> RxJava1SingleConverter.fromPublisher(webResponse.getClientResponse() .map(response -> new ResponseEntity<>( RxJava1ObservableConverter - .from(decodeResponseBody(response, resolvableType, webResponse.getMessageDecoders())), + .fromPublisher(decodeResponseBody(response, resolvableType, webResponse.getMessageDecoders())), response.getHeaders(), response.getStatusCode()))); } @@ -107,7 +107,7 @@ public class RxJava1WebResponseExtractors { */ public static WebResponseExtractor> headers() { return webResponse -> RxJava1SingleConverter - .from(webResponse.getClientResponse().map(resp -> resp.getHeaders())); + .fromPublisher(webResponse.getClientResponse().map(resp -> resp.getHeaders())); } protected static Flux decodeResponseBody(ClientHttpResponse response, ResolvableType responseType, diff --git a/spring-web-reactive/src/main/java/org/springframework/web/reactive/config/WebReactiveConfiguration.java b/spring-web-reactive/src/main/java/org/springframework/web/reactive/config/WebReactiveConfiguration.java index 65cf61f880..6382e94e8e 100644 --- a/spring-web-reactive/src/main/java/org/springframework/web/reactive/config/WebReactiveConfiguration.java +++ b/spring-web-reactive/src/main/java/org/springframework/web/reactive/config/WebReactiveConfiguration.java @@ -20,7 +20,7 @@ import java.util.HashMap; import java.util.List; import java.util.Map; -import reactor.core.converter.DependencyUtils; +import reactor.core.converter.Converters; import org.springframework.beans.BeanUtils; import org.springframework.beans.factory.BeanInitializationException; @@ -288,7 +288,7 @@ public class WebReactiveConfiguration implements ApplicationContextAware { */ protected void addFormatters(FormatterRegistry registry) { registry.addConverter(new MonoToCompletableFutureConverter()); - if (DependencyUtils.hasRxJava1()) { + if (Converters.hasRxJava1()) { registry.addConverter(new ReactorToRxJava1Converter()); } } diff --git a/spring-web-reactive/src/test/java/org/springframework/web/reactive/result/method/annotation/HttpEntityArgumentResolverTests.java b/spring-web-reactive/src/test/java/org/springframework/web/reactive/result/method/annotation/HttpEntityArgumentResolverTests.java index 86085d67e4..839960eaed 100644 --- a/spring-web-reactive/src/test/java/org/springframework/web/reactive/result/method/annotation/HttpEntityArgumentResolverTests.java +++ b/spring-web-reactive/src/test/java/org/springframework/web/reactive/result/method/annotation/HttpEntityArgumentResolverTests.java @@ -156,7 +156,7 @@ public class HttpEntityArgumentResolverTests { ResolvableType type = httpEntityType(forClassWithGenerics(Single.class, String.class)); HttpEntity> entity = resolveValueWithEmptyBody(type); - TestSubscriber.subscribe(RxJava1SingleConverter.from(entity.getBody())) + TestSubscriber.subscribe(RxJava1SingleConverter.toPublisher(entity.getBody())) .assertNoValues() .assertError(ServerWebInputException.class); } @@ -166,7 +166,7 @@ public class HttpEntityArgumentResolverTests { ResolvableType type = httpEntityType(forClassWithGenerics(Observable.class, String.class)); HttpEntity> entity = resolveValueWithEmptyBody(type); - TestSubscriber.subscribe(RxJava1ObservableConverter.from(entity.getBody())) + TestSubscriber.subscribe(RxJava1ObservableConverter.toPublisher(entity.getBody())) .assertNoError() .assertComplete() .assertNoValues(); diff --git a/spring-web-reactive/src/test/java/org/springframework/web/reactive/result/method/annotation/RequestBodyArgumentResolverTests.java b/spring-web-reactive/src/test/java/org/springframework/web/reactive/result/method/annotation/RequestBodyArgumentResolverTests.java index ecd98007eb..b75c5aa017 100644 --- a/spring-web-reactive/src/test/java/org/springframework/web/reactive/result/method/annotation/RequestBodyArgumentResolverTests.java +++ b/spring-web-reactive/src/test/java/org/springframework/web/reactive/result/method/annotation/RequestBodyArgumentResolverTests.java @@ -165,12 +165,12 @@ public class RequestBodyArgumentResolverTests { ResolvableType type = forClassWithGenerics(Single.class, String.class); Single single = resolveValueWithEmptyBody(type, true); - TestSubscriber.subscribe(RxJava1SingleConverter.from(single)) + TestSubscriber.subscribe(RxJava1SingleConverter.toPublisher(single)) .assertNoValues() .assertError(ServerWebInputException.class); single = resolveValueWithEmptyBody(type, false); - TestSubscriber.subscribe(RxJava1SingleConverter.from(single)) + TestSubscriber.subscribe(RxJava1SingleConverter.toPublisher(single)) .assertNoValues() .assertError(ServerWebInputException.class); } @@ -180,12 +180,12 @@ public class RequestBodyArgumentResolverTests { ResolvableType type = forClassWithGenerics(Observable.class, String.class); Observable observable = resolveValueWithEmptyBody(type, true); - TestSubscriber.subscribe(RxJava1ObservableConverter.from(observable)) + TestSubscriber.subscribe(RxJava1ObservableConverter.toPublisher(observable)) .assertNoValues() .assertError(ServerWebInputException.class); observable = resolveValueWithEmptyBody(type, false); - TestSubscriber.subscribe(RxJava1ObservableConverter.from(observable)) + TestSubscriber.subscribe(RxJava1ObservableConverter.toPublisher(observable)) .assertNoValues() .assertComplete(); }