Skip to content

Commit aa02167

Browse files
committed
Drop support for RxJava 1.
Closes #2469
1 parent d9f5248 commit aa02167

12 files changed

+30
-218
lines changed

Diff for: pom.xml

-14
Original file line numberDiff line numberDiff line change
@@ -112,20 +112,6 @@
112112

113113
<!-- RxJava -->
114114

115-
<dependency>
116-
<groupId>io.reactivex</groupId>
117-
<artifactId>rxjava</artifactId>
118-
<version>${rxjava}</version>
119-
<optional>true</optional>
120-
</dependency>
121-
122-
<dependency>
123-
<groupId>io.reactivex</groupId>
124-
<artifactId>rxjava-reactive-streams</artifactId>
125-
<version>${rxjava-reactive-streams}</version>
126-
<optional>true</optional>
127-
</dependency>
128-
129115
<dependency>
130116
<groupId>io.reactivex.rxjava2</groupId>
131117
<artifactId>rxjava</artifactId>

Diff for: src/main/java/org/springframework/data/repository/util/ReactiveWrapperConverters.java

-50
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,6 @@
2222
import kotlinx.coroutines.reactive.ReactiveFlowKt;
2323
import reactor.core.publisher.Flux;
2424
import reactor.core.publisher.Mono;
25-
import rx.Observable;
26-
import rx.Single;
2725

2826
import java.util.ArrayList;
2927
import java.util.List;
@@ -54,8 +52,6 @@
5452
* <p>
5553
* This class discovers reactive wrapper availability and their conversion support based on the class path. Reactive
5654
* wrapper types might be supported/on the class path but conversion may require additional dependencies.
57-
* <p>
58-
* <strong>Note:</strong> As of Spring Data 2.4, support for RxJava 1.x is deprecated in favor of RxJava 2 and 3.
5955
*
6056
* @author Mark Paluch
6157
* @author Oliver Gierke
@@ -71,12 +67,6 @@ public abstract class ReactiveWrapperConverters {
7167

7268
static {
7369

74-
if (ReactiveWrappers.isAvailable(ReactiveLibrary.RXJAVA1)) {
75-
76-
REACTIVE_WRAPPERS.add(RxJava1SingleWrapper.INSTANCE);
77-
REACTIVE_WRAPPERS.add(RxJava1ObservableWrapper.INSTANCE);
78-
}
79-
8070
if (ReactiveWrappers.isAvailable(ReactiveLibrary.RXJAVA2)) {
8171

8272
REACTIVE_WRAPPERS.add(RxJava2SingleWrapper.INSTANCE);
@@ -335,46 +325,6 @@ public Publisher<?> map(Object wrapper, Function<Object, Object> function) {
335325
}
336326
}
337327

338-
// -------------------------------------------------------------------------
339-
// RxJava 1 converters
340-
// -------------------------------------------------------------------------
341-
342-
/**
343-
* Wrapper for RxJava 1's {@link Single}.
344-
*/
345-
private enum RxJava1SingleWrapper implements ReactiveTypeWrapper<Single<?>> {
346-
347-
INSTANCE;
348-
349-
@Override
350-
public Class<? super Single<?>> getWrapperClass() {
351-
return Single.class;
352-
}
353-
354-
@Override
355-
public Single<?> map(Object wrapper, Function<Object, Object> function) {
356-
return ((Single<?>) wrapper).map(function::apply);
357-
}
358-
}
359-
360-
/**
361-
* Wrapper for RxJava 1's {@link Observable}.
362-
*/
363-
private enum RxJava1ObservableWrapper implements ReactiveTypeWrapper<Observable<?>> {
364-
365-
INSTANCE;
366-
367-
@Override
368-
public Class<? super Observable<?>> getWrapperClass() {
369-
return Observable.class;
370-
}
371-
372-
@Override
373-
public Observable<?> map(Object wrapper, Function<Object, Object> function) {
374-
return ((Observable<?>) wrapper).map(function::apply);
375-
}
376-
}
377-
378328
// -------------------------------------------------------------------------
379329
// RxJava 2 converters
380330
// -------------------------------------------------------------------------

Diff for: src/main/java/org/springframework/data/repository/util/ReactiveWrappers.java

+1-18
Original file line numberDiff line numberDiff line change
@@ -35,18 +35,13 @@
3535
* <p>
3636
* Supported types are discovered by their availability on the class path. This class is typically used to determine
3737
* multiplicity and whether a reactive wrapper type is acceptable for a specific operation.
38-
* <p>
39-
* <strong>Note:</strong> As of Spring Data 2.4, support for RxJava 1.x is deprecated in favor of RxJava 2 and 3.
4038
*
4139
* @author Mark Paluch
4240
* @author Christoph Strobl
4341
* @author Oliver Gierke
4442
* @author Gerrit Meier
4543
* @since 2.0
4644
* @see org.reactivestreams.Publisher
47-
* @see rx.Single
48-
* @see rx.Observable
49-
* @see rx.Completable
5045
* @see io.reactivex.Single
5146
* @see io.reactivex.Maybe
5247
* @see io.reactivex.Observable
@@ -65,12 +60,6 @@ public abstract class ReactiveWrappers {
6560
private static final boolean PROJECT_REACTOR_PRESENT = ClassUtils.isPresent("reactor.core.publisher.Flux",
6661
ReactiveWrappers.class.getClassLoader());
6762

68-
@Deprecated
69-
private static final boolean RXJAVA1_PRESENT = ClassUtils.isPresent("rx.Observable",
70-
ReactiveWrappers.class.getClassLoader())
71-
&& ClassUtils.isPresent("rx.RxReactiveStreams",
72-
ReactiveWrappers.class.getClassLoader());
73-
7463
private static final boolean RXJAVA2_PRESENT = ClassUtils.isPresent("io.reactivex.Flowable",
7564
ReactiveWrappers.class.getClassLoader());
7665

@@ -91,11 +80,7 @@ public enum ReactiveLibrary {
9180

9281
PROJECT_REACTOR,
9382

94-
/**
95-
* @deprecated since 2.4, use RxJava 2 or 3 instead.
96-
*/
97-
@Deprecated
98-
RXJAVA1, RXJAVA2, RXJAVA3, KOTLIN_COROUTINES;
83+
RXJAVA2, RXJAVA3, KOTLIN_COROUTINES;
9984
}
10085

10186
/**
@@ -121,8 +106,6 @@ public static boolean isAvailable(ReactiveLibrary reactiveLibrary) {
121106
switch (reactiveLibrary) {
122107
case PROJECT_REACTOR:
123108
return PROJECT_REACTOR_PRESENT;
124-
case RXJAVA1:
125-
return RXJAVA1_PRESENT;
126109
case RXJAVA2:
127110
return RXJAVA2_PRESENT;
128111
case RXJAVA3:

Diff for: src/test/java/org/springframework/data/repository/core/support/QueryExecutionResultHandlerUnitTests.java

+18-17
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,14 @@
1818
import static java.util.Arrays.*;
1919
import static org.assertj.core.api.Assertions.*;
2020

21+
import io.reactivex.rxjava3.core.Completable;
22+
import io.reactivex.rxjava3.core.Observable;
23+
import io.reactivex.rxjava3.core.Single;
2124
import io.vavr.control.Option;
2225
import io.vavr.control.Try;
2326
import lombok.Value;
2427
import reactor.core.publisher.Flux;
2528
import reactor.core.publisher.Mono;
26-
import rx.Completable;
27-
import rx.Observable;
28-
import rx.Single;
2929

3030
import java.lang.reflect.Method;
3131
import java.math.BigDecimal;
@@ -41,6 +41,7 @@
4141
import org.assertj.core.api.SoftAssertions;
4242
import org.junit.jupiter.api.Test;
4343
import org.reactivestreams.Publisher;
44+
4445
import org.springframework.dao.InvalidDataAccessApiUsageException;
4546
import org.springframework.data.repository.Repository;
4647
import org.springframework.data.util.Streamable;
@@ -120,7 +121,7 @@ void convertsRxJavaSingleIntoPublisher() throws Exception {
120121
assertThat(result).isInstanceOf(Publisher.class);
121122

122123
Mono<Entity> mono = Mono.from((Publisher<Entity>) result);
123-
assertThat(mono.block()).isEqualTo(entity.toBlocking().value());
124+
assertThat(mono.block()).isEqualTo(entity.blockingGet());
124125
}
125126

126127
@Test // DATACMNS-836
@@ -133,7 +134,7 @@ void convertsRxJavaSingleIntoMono() throws Exception {
133134
assertThat(result).isInstanceOf(Mono.class);
134135

135136
Mono<Entity> mono = (Mono<Entity>) result;
136-
assertThat(mono.block()).isEqualTo(entity.toBlocking().value());
137+
assertThat(mono.block()).isEqualTo(entity.blockingGet());
137138
}
138139

139140
@Test // DATACMNS-836
@@ -146,7 +147,7 @@ void convertsRxJavaSingleIntoFlux() throws Exception {
146147
assertThat(result).isInstanceOf(Flux.class);
147148

148149
Flux<Entity> flux = (Flux<Entity>) result;
149-
assertThat(flux.next().block()).isEqualTo(entity.toBlocking().value());
150+
assertThat(flux.next().block()).isEqualTo(entity.blockingGet());
150151
}
151152

152153
@Test // DATACMNS-836
@@ -159,7 +160,7 @@ void convertsRxJavaObservableIntoPublisher() throws Exception {
159160
assertThat(result).isInstanceOf(Publisher.class);
160161

161162
Mono<Entity> mono = Mono.from((Publisher<Entity>) result);
162-
assertThat(mono.block()).isEqualTo(entity.toBlocking().first());
163+
assertThat(mono.block()).isEqualTo(entity.blockingFirst());
163164
}
164165

165166
@Test // DATACMNS-836
@@ -172,7 +173,7 @@ void convertsRxJavaObservableIntoMono() throws Exception {
172173
assertThat(result).isInstanceOf(Mono.class);
173174

174175
Mono<Entity> mono = (Mono<Entity>) result;
175-
assertThat(mono.block()).isEqualTo(entity.toBlocking().first());
176+
assertThat(mono.block()).isEqualTo(entity.blockingFirst());
176177
}
177178

178179
@Test // DATACMNS-836
@@ -185,7 +186,7 @@ void convertsRxJavaObservableIntoFlux() throws Exception {
185186
assertThat(result).isInstanceOf(Flux.class);
186187

187188
Flux<Entity> flux = (Flux<Entity>) result;
188-
assertThat(flux.next().block()).isEqualTo(entity.toBlocking().first());
189+
assertThat(flux.next().block()).isEqualTo(entity.blockingFirst());
189190
}
190191

191192
@Test // DATACMNS-836
@@ -198,7 +199,7 @@ void convertsRxJavaObservableIntoSingle() throws Exception {
198199
assertThat(result).isInstanceOf(Single.class);
199200

200201
Single<Entity> single = (Single<Entity>) result;
201-
assertThat(single.toBlocking().value()).isEqualTo(entity.toBlocking().first());
202+
assertThat(single.blockingGet()).isEqualTo(entity.blockingFirst());
202203
}
203204

204205
@Test // DATACMNS-836
@@ -211,7 +212,7 @@ void convertsRxJavaSingleIntoObservable() throws Exception {
211212
assertThat(result).isInstanceOf(Observable.class);
212213

213214
Observable<Entity> observable = (Observable<Entity>) result;
214-
assertThat(observable.toBlocking().first()).isEqualTo(entity.toBlocking().value());
215+
assertThat(observable.blockingFirst()).isEqualTo(entity.blockingGet());
215216
}
216217

217218
@Test // DATACMNS-836
@@ -224,7 +225,7 @@ void convertsReactorMonoIntoSingle() throws Exception {
224225
assertThat(result).isInstanceOf(Single.class);
225226

226227
Single<Entity> single = (Single<Entity>) result;
227-
assertThat(single.toBlocking().value()).isEqualTo(entity.block());
228+
assertThat(single.blockingGet()).isEqualTo(entity.block());
228229
}
229230

230231
@Test // DATACMNS-836
@@ -237,7 +238,7 @@ void convertsReactorMonoIntoCompletable() throws Exception {
237238
assertThat(result).isInstanceOf(Completable.class);
238239

239240
Completable completable = (Completable) result;
240-
assertThat(completable.get()).isNull();
241+
completable.blockingAwait();
241242
}
242243

243244
@Test // DATACMNS-836
@@ -250,7 +251,7 @@ void convertsReactorMonoIntoCompletableWithException() throws Exception {
250251
assertThat(result).isInstanceOf(Completable.class);
251252

252253
Completable completable = (Completable) result;
253-
assertThat(completable.get()).isInstanceOf(InvalidDataAccessApiUsageException.class);
254+
assertThatExceptionOfType(InvalidDataAccessApiUsageException.class).isThrownBy(completable::blockingAwait);
254255
}
255256

256257
@Test // DATACMNS-836
@@ -290,7 +291,7 @@ void convertsReactorMonoIntoObservable() throws Exception {
290291
assertThat(result).isInstanceOf(Observable.class);
291292

292293
Observable<Entity> observable = (Observable<Entity>) result;
293-
assertThat(observable.toBlocking().first()).isEqualTo(entity.block());
294+
assertThat(observable.blockingFirst()).isEqualTo(entity.block());
294295
}
295296

296297
@Test // DATACMNS-836
@@ -303,7 +304,7 @@ void convertsReactorFluxIntoSingle() throws Exception {
303304
assertThat(result).isInstanceOf(Single.class);
304305

305306
Single<Entity> single = (Single<Entity>) result;
306-
assertThat(single.toBlocking().value()).isEqualTo(entity.next().block());
307+
assertThat(single.blockingGet()).isEqualTo(entity.next().block());
307308
}
308309

309310
@Test // DATACMNS-836
@@ -316,7 +317,7 @@ void convertsReactorFluxIntoObservable() throws Exception {
316317
assertThat(result).isInstanceOf(Observable.class);
317318

318319
Observable<Entity> observable = (Observable<Entity>) result;
319-
assertThat(observable.toBlocking().first()).isEqualTo(entity.next().block());
320+
assertThat(observable.blockingFirst()).isEqualTo(entity.next().block());
320321
}
321322

322323
@Test // DATACMNS-836

Diff for: src/test/java/org/springframework/data/repository/core/support/ReactiveRepositoryInformationUnitTests.java

-30
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,8 @@
1717

1818
import static org.assertj.core.api.Assertions.*;
1919

20-
import io.reactivex.Completable;
2120
import io.reactivex.Flowable;
2221
import reactor.core.publisher.Flux;
23-
import rx.Observable;
2422

2523
import java.lang.reflect.Method;
2624

@@ -29,7 +27,6 @@
2927
import org.mockito.junit.jupiter.MockitoExtension;
3028
import org.reactivestreams.Publisher;
3129

32-
import org.springframework.data.repository.Repository;
3330
import org.springframework.data.repository.core.RepositoryMetadata;
3431
import org.springframework.data.repository.reactive.ReactiveCrudRepository;
3532
import org.springframework.data.repository.reactive.ReactiveSortingRepository;
@@ -47,26 +44,6 @@ class ReactiveRepositoryInformationUnitTests {
4744

4845
static final Class<ReactiveJavaInterfaceWithGenerics> BASE_CLASS = ReactiveJavaInterfaceWithGenerics.class;
4946

50-
@Test // DATACMNS-836
51-
void discoversRxJava1MethodWithoutComparingReturnType() throws Exception {
52-
53-
Method reference = extractTargetMethodFromRepository(RxJava1InterfaceWithGenerics.class, "deleteAll");
54-
55-
assertThat(reference.getDeclaringClass()).isEqualTo(ReactiveCrudRepository.class);
56-
assertThat(reference.getName()).isEqualTo("deleteAll");
57-
}
58-
59-
@Test // DATACMNS-836
60-
void discoversRxJava1MethodWithConvertibleArguments() throws Exception {
61-
62-
Method reference = extractTargetMethodFromRepository(RxJava1InterfaceWithGenerics.class, "saveAll",
63-
Observable.class);
64-
65-
assertThat(reference.getDeclaringClass()).isEqualTo(ReactiveCrudRepository.class);
66-
assertThat(reference.getName()).isEqualTo("saveAll");
67-
assertThat(reference.getParameterTypes()[0]).isEqualTo(Publisher.class);
68-
}
69-
7047
@Test // DATACMNS-988
7148
void discoversRxJava2MethodWithoutComparingReturnType() throws Exception {
7249

@@ -136,13 +113,6 @@ private Method extractTargetMethodFromRepository(Class<?> repositoryType, String
136113
return composition.findMethod(repositoryType.getMethod(methodName, args)).get();
137114
}
138115

139-
interface RxJava1InterfaceWithGenerics extends Repository<User, String> {
140-
141-
Observable<User> saveAll(Observable<User> entities);
142-
143-
Completable deleteAll();
144-
}
145-
146116
interface RxJava2InterfaceWithGenerics extends RxJava2CrudRepository<User, String> {}
147117

148118
interface ReactiveJavaInterfaceWithGenerics extends ReactiveCrudRepository<User, String> {}

0 commit comments

Comments
 (0)