Skip to content

Commit 20a1220

Browse files
mp911deschauder
authored andcommitted
Drop support for RxJava 1.
Closes #2469
1 parent 5a59e43 commit 20a1220

12 files changed

+30
-220
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
@@ -72,12 +68,6 @@ public abstract class ReactiveWrapperConverters {
7268

7369
static {
7470

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

8373
REACTIVE_WRAPPERS.add(RxJava2SingleWrapper.INSTANCE);
@@ -341,46 +331,6 @@ public Publisher<?> map(Object wrapper, Function<Object, Object> function) {
341331
}
342332
}
343333

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

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

+1-20
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,6 @@
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
@@ -45,9 +43,6 @@
4543
* @author Hantsy Bai
4644
* @since 2.0
4745
* @see org.reactivestreams.Publisher
48-
* @see rx.Single
49-
* @see rx.Observable
50-
* @see rx.Completable
5146
* @see io.reactivex.Single
5247
* @see io.reactivex.Maybe
5348
* @see io.reactivex.Observable
@@ -68,12 +63,6 @@ public abstract class ReactiveWrappers {
6863
private static final boolean PROJECT_REACTOR_PRESENT = ClassUtils.isPresent("reactor.core.publisher.Flux",
6964
ReactiveWrappers.class.getClassLoader());
7065

71-
@Deprecated
72-
private static final boolean RXJAVA1_PRESENT = ClassUtils.isPresent("rx.Observable",
73-
ReactiveWrappers.class.getClassLoader())
74-
&& ClassUtils.isPresent("rx.RxReactiveStreams",
75-
ReactiveWrappers.class.getClassLoader());
76-
7766
@Deprecated
7867
private static final boolean RXJAVA2_PRESENT = ClassUtils.isPresent("io.reactivex.Flowable",
7968
ReactiveWrappers.class.getClassLoader());
@@ -98,17 +87,11 @@ public enum ReactiveLibrary {
9887

9988
PROJECT_REACTOR,
10089

101-
/**
102-
* @deprecated since 2.4, use RxJava 3 instead. To be removed with Spring Data 3.0.
103-
*/
104-
@Deprecated
105-
RXJAVA1,
106-
10790
/**
10891
* @deprecated since 2.6, use RxJava 3 instead. To be removed with Spring Data 3.0.
10992
*/
11093
@Deprecated
111-
RXJAVA2, RXJAVA3, KOTLIN_COROUTINES, MUTINY;
94+
RXJAVA2, RXJAVA3, KOTLIN_COROUTINES;
11295
}
11396

11497
/**
@@ -134,8 +117,6 @@ public static boolean isAvailable(ReactiveLibrary reactiveLibrary) {
134117
switch (reactiveLibrary) {
135118
case PROJECT_REACTOR:
136119
return PROJECT_REACTOR_PRESENT;
137-
case RXJAVA1:
138-
return RXJAVA1_PRESENT;
139120
case RXJAVA2:
140121
return RXJAVA2_PRESENT;
141122
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)