Skip to content

Commit 5091ed2

Browse files
authored
4.x: Cleanup; build, safevarargs, small typos (#8183)
* 4.x: Cleanup; build, safevarargs, small typos * Rename validators to CheckXXXTest & some try() cleanup * isEmpty cleanup * append fixes, typo fixes, unused removals * DisposableContainer +tests
1 parent a23d855 commit 5091ed2

94 files changed

Lines changed: 387 additions & 464 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

build.gradle

Lines changed: 9 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -179,17 +179,18 @@ jmh {
179179

180180
def isCI = System.getenv("CI") != null
181181
def testLoggingConfig = ["skipped", "failed"]
182+
def parallelism = Runtime.runtime.availableProcessors()
183+
182184
if (!isCI) {
183185
testLoggingConfig = ["failed"]
186+
parallelism = parallelism.intdiv(2) ?: 1
184187
}
185188

186189
test {
187190
maxHeapSize = "1200m"
188-
if (System.getenv("CI") != null) {
189-
maxParallelForks = Runtime.runtime.availableProcessors()
190-
} else {
191-
maxParallelForks = Runtime.runtime.availableProcessors().intdiv(2) ?: 1
192-
}
191+
maxParallelForks = parallelism
192+
timeout = Duration.ofMinutes(30)
193+
193194
useJUnitPlatform()
194195
}
195196

@@ -206,19 +207,8 @@ tasks.register('testNG', Test) {
206207
useTestNG()
207208

208209
maxHeapSize = "1200m"
209-
if (System.getenv("CI") != null) {
210-
maxParallelForks = Runtime.runtime.availableProcessors()
211-
} else {
212-
maxParallelForks = Runtime.runtime.availableProcessors().intdiv(2) ?: 1
213-
}
214-
// maxParallelForks = 1
215-
216-
// Ensure JUnit-compatible XML output in the standard location
217-
reports {
218-
html.required = true
219-
junitXml.required = true
220-
junitXml.outputLocation = file("${buildDir}/test-results/test") // ← important
221-
}
210+
maxParallelForks = parallelism
211+
timeout = Duration.ofMinutes(30)
222212

223213
// Ensure JUnit-compatible XML output in the standard location
224214
reports {
@@ -307,7 +297,7 @@ if (project.hasProperty("releaseMode")) {
307297
}
308298
mavenPublishing {
309299
// or when publishing to https://central.sonatype.com/
310-
publishToMavenCentral(true)
300+
publishToMavenCentral(true, DeploymentValidation.PUBLISHED)
311301

312302
// signAllPublications()
313303
}

docs/Creating-Observables.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,8 +99,8 @@ When a consumer subscribes, the given `java.util.concurrent.Callable` is invoked
9999
```java
100100
Callable<String> callable = () -> {
101101
System.out.println("Hello World!");
102-
return "Hello World!");
103-
}
102+
return "Hello World!";
103+
};
104104

105105
Observable<String> observable = Observable.fromCallable(callable);
106106

docs/What's-different-in-2.0.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ Observable.just(1).map(v -> null)
6060
This means that `Observable<Void>` can no longer emit any values but only terminate normally or with an exception. API designers may instead choose to define `Observable<Object>` with no guarantee on what `Object` will be (which should be irrelevant anyway). For example, if one needs a signaller-like source, a shared enum can be defined and its solo instance `onNext`'d:
6161

6262
```java
63-
enum Irrelevant { INSTANCE; }
63+
enum Irrelevant { INSTANCE}
6464

6565
Observable<Object> source = Observable.create((ObservableEmitter<Object> emitter) -> {
6666
System.out.println("Side-effect 1");

src/main/java/io/reactivex/rxjava4/core/Completable.java

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,6 @@ public abstract class Completable implements CompletableSource {
122122
@CheckReturnValue
123123
@NonNull
124124
@SchedulerSupport(SchedulerSupport.NONE)
125-
@SafeVarargs
126125
public static Completable ambArray(@NonNull CompletableSource... sources) {
127126
Objects.requireNonNull(sources, "sources is null");
128127
if (sources.length == 0) {
@@ -190,7 +189,6 @@ public static Completable complete() {
190189
@CheckReturnValue
191190
@NonNull
192191
@SchedulerSupport(SchedulerSupport.NONE)
193-
@SafeVarargs
194192
public static Completable concatArray(@NonNull CompletableSource... sources) {
195193
return concatArray(CompletableConcatConfig.DEFAULT, sources);
196194
}
@@ -212,7 +210,6 @@ public static Completable concatArray(@NonNull CompletableSource... sources) {
212210
@CheckReturnValue
213211
@NonNull
214212
@SchedulerSupport(SchedulerSupport.NONE)
215-
@SafeVarargs
216213
public static Completable concatArray(@NonNull CompletableConcatConfig config, @NonNull CompletableSource... sources) {
217214
Objects.requireNonNull(sources, "sources is null");
218215
Objects.requireNonNull(config, "config is null");
@@ -775,7 +772,6 @@ public static Completable fromSupplier(@NonNull Supplier<?> supplier) {
775772
@CheckReturnValue
776773
@NonNull
777774
@SchedulerSupport(SchedulerSupport.NONE)
778-
@SafeVarargs
779775
public static Completable mergeArray(@NonNull CompletableSource... sources) {
780776
return mergeArray(CompletableMergeConfig.DEFAULT, sources);
781777
}
@@ -906,7 +902,6 @@ public static Completable merge(@NonNull Publisher<@NonNull ? extends Completabl
906902
@CheckReturnValue
907903
@NonNull
908904
@SchedulerSupport(SchedulerSupport.NONE)
909-
@SafeVarargs
910905
public static Completable mergeArray(@NonNull CompletableMergeConfig config, @NonNull CompletableSource... sources) {
911906
Objects.requireNonNull(sources, "sources is null");
912907
Objects.requireNonNull(config, "config is null");
@@ -3262,8 +3257,8 @@ public final TestObserver<Void> test() {
32623257
}
32633258

32643259
/**
3265-
* Creates a {@link TestObserver} optionally in cancelled state, then subscribes it to this {@code Completable}.
3266-
* @param dispose if {@code true}, the {@code TestObserver} will be cancelled before subscribing to this
3260+
* Creates a {@link TestObserver} optionally in canceled state, then subscribes it to this {@code Completable}.
3261+
* @param dispose if {@code true}, the {@code TestObserver} will be canceled before subscribing to this
32673262
* {@code Completable}.
32683263
* <p>
32693264
* <img width="640" height="499" src="https://raw.github.com/wiki/ReactiveX/RxJava/images/rx-operators/Completable.test.b.png" alt="">
@@ -3332,7 +3327,7 @@ public static Completable fromCompletionStage(@NonNull CompletionStage<?> stage)
33323327
* The upstream can be canceled by converting the resulting {@code CompletionStage} into
33333328
* {@link CompletableFuture} via {@link CompletionStage#toCompletableFuture()} and
33343329
* calling {@link CompletableFuture#cancel(boolean)} on it.
3335-
* The upstream will be also cancelled if the resulting {@code CompletionStage} is converted to and
3330+
* The upstream will be also canceled if the resulting {@code CompletionStage} is converted to and
33363331
* completed manually by {@link CompletableFuture#complete(Object)} or {@link CompletableFuture#completeExceptionally(Throwable)}.
33373332
* <p>
33383333
* {@code CompletionStage}s don't have a notion of emptiness and allow {@code null}s, therefore, one can either use

src/main/java/io/reactivex/rxjava4/core/CompletionStageDisposable.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ public CompletionStageDisposable(@NonNull CompletionStage<T> stage, @NonNull Dis
8686
* Await the completion of the current stage.
8787
*/
8888
public void await() {
89-
state.lazySet(true);;
89+
state.lazySet(true);
9090
AwaitCoordinatorStatic.await(stage);
9191
}
9292

@@ -95,15 +95,15 @@ public void await() {
9595
* @param canceller the canceller link
9696
*/
9797
public void await(DisposableContainer canceller) {
98-
state.lazySet(true);;
98+
state.lazySet(true);
9999
AwaitCoordinatorStatic.await(stage, canceller);
100100
}
101101

102102
/**
103103
* Indicate this instance is deliberately not awaiting its stage.
104104
*/
105105
public void ignore() {
106-
state.lazySet(true);;
106+
state.lazySet(true);
107107
}
108108

109109
@Override

src/main/java/io/reactivex/rxjava4/core/Streamable.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ static <T> Streamable<T> fromPublisher(@NonNull Flow.Publisher<T> source, @NonNu
186186
for(var stage : stages) {
187187
list.add(stage);
188188
}
189-
while (list.size() != 0) {
189+
while (!list.isEmpty()) {
190190
var winner = AwaitCoordinatorStatic.awaitFirstIndex(list, emitter.canceller());
191191
emitter.emit((CompletionStage<T>)list.remove(winner));
192192
}
@@ -208,7 +208,7 @@ static <T> Streamable<T> fromPublisher(@NonNull Flow.Publisher<T> source, @NonNu
208208
}
209209
}, emitter.canceller(), exec)) {
210210
mainSource.await(emitter.canceller());
211-
};
211+
}
212212
}, exec);
213213
}
214214

src/main/java/io/reactivex/rxjava4/exceptions/CompositeException.java

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -114,28 +114,22 @@ public synchronized Throwable getCause() { // NOPMD
114114
for (Throwable inner : exceptions) {
115115
int depth = 0;
116116
while (inner != null) {
117-
for (int i = 0; i < depth; i++) {
118-
aggregateMessage.append(" ");
119-
}
117+
aggregateMessage.repeat(" ", Math.max(0, depth));
120118
aggregateMessage.append("|-- ");
121119
aggregateMessage.append(inner.getClass().getCanonicalName()).append(": ");
122120
String innerMessage = inner.getMessage();
123121
if (innerMessage != null && innerMessage.contains(separator)) {
124122
aggregateMessage.append(separator);
125123
for (String line : innerMessage.split(separator)) {
126-
for (int i = 0; i < depth + 2; i++) {
127-
aggregateMessage.append(" ");
128-
}
124+
aggregateMessage.repeat(" ", Math.max(0, depth + 2));
129125
aggregateMessage.append(line).append(separator);
130126
}
131127
} else {
132128
aggregateMessage.append(innerMessage);
133129
aggregateMessage.append(separator);
134130
}
135131

136-
for (int i = 0; i < depth + 2; i++) {
137-
aggregateMessage.append(" ");
138-
}
132+
aggregateMessage.repeat(" ", Math.max(0, depth + 2));
139133
StackTraceElement[] st = inner.getStackTrace();
140134
if (st.length > 0) {
141135
aggregateMessage.append("at ").append(st[0]).append(separator);
@@ -149,9 +143,7 @@ public synchronized Throwable getCause() { // NOPMD
149143
} else {
150144
inner = inner.getCause();
151145
if (inner != null) {
152-
for (int i = 0; i < depth + 2; i++) {
153-
aggregateMessage.append(" ");
154-
}
146+
aggregateMessage.repeat(" ", Math.max(0, depth + 2));
155147
aggregateMessage.append("|-- ");
156148
aggregateMessage.append("(cause not expanded again) ");
157149
aggregateMessage.append(inner.getClass().getCanonicalName()).append(": ");

src/main/java/io/reactivex/rxjava4/internal/operators/flowable/FlowableWindowBoundarySelector.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -297,7 +297,7 @@ else if (o instanceof WindowEndSubscriberIntercept) {
297297

298298
continue;
299299
}
300-
else if (openDone && windows.size() == 0) {
300+
else if (openDone && windows.isEmpty()) {
301301
upstream.cancel();
302302
startSubscriber.cancel();
303303
resources.dispose();

src/main/java/io/reactivex/rxjava4/internal/operators/observable/ObservableWindowBoundarySelector.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -282,7 +282,7 @@ else if (o instanceof WindowEndObserverIntercept) {
282282

283283
continue;
284284
}
285-
else if (openDone && windows.size() == 0) {
285+
else if (openDone && windows.isEmpty()) {
286286
upstream.dispose();
287287
startObserver.dispose();
288288
resources.dispose();

src/main/java/io/reactivex/rxjava4/internal/operators/streamable/StreamableJust.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
public record StreamableJust<T>(@NonNull T item) implements Streamable<T> {
2424

2525
public StreamableJust(T item) {
26-
this.item = Objects.requireNonNull(item, "item is null");;
26+
this.item = Objects.requireNonNull(item, "item is null");
2727
}
2828

2929
@Override

0 commit comments

Comments
 (0)