The following issues were found
src/test/java/io/reactivex/rxjava3/internal/util/OpenHashSetTest.java
9 issues
Line: 38
}
@Test
public void addRemoveCollision() {
Value v1 = new Value();
Value v2 = new Value();
OpenHashSet<Value> set = new OpenHashSet<>();
Reported by PMD.
Line: 44
OpenHashSet<Value> set = new OpenHashSet<>();
assertTrue(set.add(v1));
assertFalse(set.add(v1));
assertFalse(set.remove(v2));
Reported by PMD.
Line: 46
assertTrue(set.add(v1));
assertFalse(set.add(v1));
assertFalse(set.remove(v2));
assertTrue(set.add(v2));
Reported by PMD.
Line: 48
assertFalse(set.add(v1));
assertFalse(set.remove(v2));
assertTrue(set.add(v2));
assertFalse(set.add(v2));
Reported by PMD.
Line: 50
assertFalse(set.remove(v2));
assertTrue(set.add(v2));
assertFalse(set.add(v2));
assertTrue(set.remove(v2));
Reported by PMD.
Line: 52
assertTrue(set.add(v2));
assertFalse(set.add(v2));
assertTrue(set.remove(v2));
assertFalse(set.remove(v2));
}
Reported by PMD.
Line: 54
assertFalse(set.add(v2));
assertTrue(set.remove(v2));
assertFalse(set.remove(v2));
}
}
Reported by PMD.
Line: 56
assertTrue(set.remove(v2));
assertFalse(set.remove(v2));
}
}
Reported by PMD.
Line: 16
package io.reactivex.rxjava3.internal.util;
import static org.junit.Assert.*;
import org.junit.Test;
import io.reactivex.rxjava3.core.RxJavaTest;
Reported by PMD.
src/test/java/io/reactivex/rxjava3/internal/util/NotificationLiteTest.java
9 issues
Line: 28
public class NotificationLiteTest extends RxJavaTest {
@Test
public void acceptFullObserver() {
TestObserverEx<Integer> to = new TestObserverEx<>();
Disposable d = Disposable.empty();
assertFalse(NotificationLite.acceptFull(NotificationLite.disposable(d), to));
Reported by PMD.
Line: 33
Disposable d = Disposable.empty();
assertFalse(NotificationLite.acceptFull(NotificationLite.disposable(d), to));
to.assertSubscribed();
to.dispose();
Reported by PMD.
Line: 39
to.dispose();
assertTrue(d.isDisposed());
}
@Test
public void errorNotificationCompare() {
TestException ex = new TestException();
Reported by PMD.
Line: 39
to.dispose();
assertTrue(d.isDisposed());
}
@Test
public void errorNotificationCompare() {
TestException ex = new TestException();
Reported by PMD.
Line: 43
}
@Test
public void errorNotificationCompare() {
TestException ex = new TestException();
Object n1 = NotificationLite.error(ex);
assertEquals(ex.hashCode(), n1.hashCode());
Reported by PMD.
Line: 47
TestException ex = new TestException();
Object n1 = NotificationLite.error(ex);
assertEquals(ex.hashCode(), n1.hashCode());
assertNotEquals(n1, NotificationLite.complete());
}
}
Reported by PMD.
Line: 47
TestException ex = new TestException();
Object n1 = NotificationLite.error(ex);
assertEquals(ex.hashCode(), n1.hashCode());
assertNotEquals(n1, NotificationLite.complete());
}
}
Reported by PMD.
Line: 16
package io.reactivex.rxjava3.internal.util;
import static org.junit.Assert.*;
import org.junit.Test;
import io.reactivex.rxjava3.core.RxJavaTest;
import io.reactivex.rxjava3.disposables.*;
Reported by PMD.
Line: 21
import org.junit.Test;
import io.reactivex.rxjava3.core.RxJavaTest;
import io.reactivex.rxjava3.disposables.*;
import io.reactivex.rxjava3.exceptions.TestException;
import io.reactivex.rxjava3.testsupport.TestObserverEx;
public class NotificationLiteTest extends RxJavaTest {
Reported by PMD.
src/test/java/io/reactivex/rxjava3/validators/PublicFinalMethods.java
9 issues
Line: 32
static void scan(Class<?> clazz) {
for (Method m : clazz.getMethods()) {
if (m.getDeclaringClass() == clazz) {
if ((m.getModifiers() & Modifier.STATIC) == 0) {
if ((m.getModifiers() & (Modifier.PUBLIC | Modifier.FINAL)) == Modifier.PUBLIC) {
fail("Not final: " + m);
}
}
}
Reported by PMD.
Line: 33
for (Method m : clazz.getMethods()) {
if (m.getDeclaringClass() == clazz) {
if ((m.getModifiers() & Modifier.STATIC) == 0) {
if ((m.getModifiers() & (Modifier.PUBLIC | Modifier.FINAL)) == Modifier.PUBLIC) {
fail("Not final: " + m);
}
}
}
}
Reported by PMD.
Line: 33
for (Method m : clazz.getMethods()) {
if (m.getDeclaringClass() == clazz) {
if ((m.getModifiers() & Modifier.STATIC) == 0) {
if ((m.getModifiers() & (Modifier.PUBLIC | Modifier.FINAL)) == Modifier.PUBLIC) {
fail("Not final: " + m);
}
}
}
}
Reported by PMD.
Line: 42
}
@Test
public void flowable() {
scan(Flowable.class);
}
@Test
public void observable() {
Reported by PMD.
Line: 47
}
@Test
public void observable() {
scan(Observable.class);
}
@Test
public void single() {
Reported by PMD.
Line: 52
}
@Test
public void single() {
scan(Single.class);
}
@Test
public void completable() {
Reported by PMD.
Line: 57
}
@Test
public void completable() {
scan(Completable.class);
}
@Test
public void maybe() {
Reported by PMD.
Line: 62
}
@Test
public void maybe() {
scan(Maybe.class);
}
}
Reported by PMD.
Line: 22
import org.junit.Test;
import io.reactivex.rxjava3.core.*;
/**
* Verifies that instance methods of the base reactive classes are all declared final.
*/
public class PublicFinalMethods {
Reported by PMD.
src/test/java/io/reactivex/rxjava3/internal/util/CrashingIterable.java
9 issues
Line: 25
* of method invocations on iterator(), hasNext() and next().
*/
public final class CrashingIterable implements Iterable<Integer> {
int crashOnIterator;
final int crashOnHasNext;
final int crashOnNext;
Reported by PMD.
Line: 27
public final class CrashingIterable implements Iterable<Integer> {
int crashOnIterator;
final int crashOnHasNext;
final int crashOnNext;
public CrashingIterable(int crashOnIterator, int crashOnHasNext, int crashOnNext) {
this.crashOnIterator = crashOnIterator;
Reported by PMD.
Line: 29
final int crashOnHasNext;
final int crashOnNext;
public CrashingIterable(int crashOnIterator, int crashOnHasNext, int crashOnNext) {
this.crashOnIterator = crashOnIterator;
this.crashOnHasNext = crashOnHasNext;
this.crashOnNext = crashOnNext;
Reported by PMD.
Line: 39
@Override
public Iterator<Integer> iterator() {
if (--crashOnIterator <= 0) {
throw new TestException("iterator()");
}
return new CrashingIterator(crashOnHasNext, crashOnNext);
}
Reported by PMD.
Line: 46
}
static final class CrashingIterator implements Iterator<Integer> {
int crashOnHasNext;
int crashOnNext;
int count;
Reported by PMD.
Line: 48
static final class CrashingIterator implements Iterator<Integer> {
int crashOnHasNext;
int crashOnNext;
int count;
CrashingIterator(int crashOnHasNext, int crashOnNext) {
this.crashOnHasNext = crashOnHasNext;
Reported by PMD.
Line: 50
int crashOnNext;
int count;
CrashingIterator(int crashOnHasNext, int crashOnNext) {
this.crashOnHasNext = crashOnHasNext;
this.crashOnNext = crashOnNext;
}
Reported by PMD.
Line: 59
@Override
public boolean hasNext() {
if (--crashOnHasNext <= 0) {
throw new TestException("hasNext()");
}
return true;
}
Reported by PMD.
Line: 67
@Override
public Integer next() {
if (--crashOnNext <= 0) {
throw new TestException("next()");
}
return count++;
}
Reported by PMD.
src/test/java/io/reactivex/rxjava3/internal/schedulers/IoScheduledReleaseTest.java
9 issues
Line: 28
/* This test will be stuck in a deadlock if IoScheduler.USE_SCHEDULED_RELEASE is not set */
@Test
public void scheduledRelease() {
boolean savedScheduledRelease = IoScheduler.USE_SCHEDULED_RELEASE;
IoScheduler.USE_SCHEDULED_RELEASE = true;
try {
Flowable.just("item")
.observeOn(Schedulers.io())
Reported by PMD.
Line: 32
boolean savedScheduledRelease = IoScheduler.USE_SCHEDULED_RELEASE;
IoScheduler.USE_SCHEDULED_RELEASE = true;
try {
Flowable.just("item")
.observeOn(Schedulers.io())
.firstOrError()
.map(item -> {
for (int i = 0; i < 50; i++) {
Completable.complete()
Reported by PMD.
Line: 32
boolean savedScheduledRelease = IoScheduler.USE_SCHEDULED_RELEASE;
IoScheduler.USE_SCHEDULED_RELEASE = true;
try {
Flowable.just("item")
.observeOn(Schedulers.io())
.firstOrError()
.map(item -> {
for (int i = 0; i < 50; i++) {
Completable.complete()
Reported by PMD.
Line: 32
boolean savedScheduledRelease = IoScheduler.USE_SCHEDULED_RELEASE;
IoScheduler.USE_SCHEDULED_RELEASE = true;
try {
Flowable.just("item")
.observeOn(Schedulers.io())
.firstOrError()
.map(item -> {
for (int i = 0; i < 50; i++) {
Completable.complete()
Reported by PMD.
Line: 32
boolean savedScheduledRelease = IoScheduler.USE_SCHEDULED_RELEASE;
IoScheduler.USE_SCHEDULED_RELEASE = true;
try {
Flowable.just("item")
.observeOn(Schedulers.io())
.firstOrError()
.map(item -> {
for (int i = 0; i < 50; i++) {
Completable.complete()
Reported by PMD.
Line: 32
boolean savedScheduledRelease = IoScheduler.USE_SCHEDULED_RELEASE;
IoScheduler.USE_SCHEDULED_RELEASE = true;
try {
Flowable.just("item")
.observeOn(Schedulers.io())
.firstOrError()
.map(item -> {
for (int i = 0; i < 50; i++) {
Completable.complete()
Reported by PMD.
Line: 32
boolean savedScheduledRelease = IoScheduler.USE_SCHEDULED_RELEASE;
IoScheduler.USE_SCHEDULED_RELEASE = true;
try {
Flowable.just("item")
.observeOn(Schedulers.io())
.firstOrError()
.map(item -> {
for (int i = 0; i < 50; i++) {
Completable.complete()
Reported by PMD.
Line: 32
boolean savedScheduledRelease = IoScheduler.USE_SCHEDULED_RELEASE;
IoScheduler.USE_SCHEDULED_RELEASE = true;
try {
Flowable.just("item")
.observeOn(Schedulers.io())
.firstOrError()
.map(item -> {
for (int i = 0; i < 50; i++) {
Completable.complete()
Reported by PMD.
Line: 29
/* This test will be stuck in a deadlock if IoScheduler.USE_SCHEDULED_RELEASE is not set */
@Test
public void scheduledRelease() {
boolean savedScheduledRelease = IoScheduler.USE_SCHEDULED_RELEASE;
IoScheduler.USE_SCHEDULED_RELEASE = true;
try {
Flowable.just("item")
.observeOn(Schedulers.io())
.firstOrError()
Reported by PMD.
src/test/java/io/reactivex/rxjava3/internal/schedulers/DisposeOnCancelTest.java
9 issues
Line: 28
public class DisposeOnCancelTest extends RxJavaTest {
@Test
public void basicCoverage() throws Exception {
Disposable d = Disposable.empty();
DisposeOnCancel doc = new DisposeOnCancel(d);
assertFalse(doc.cancel(true));
Reported by PMD.
Line: 28
public class DisposeOnCancelTest extends RxJavaTest {
@Test
public void basicCoverage() throws Exception {
Disposable d = Disposable.empty();
DisposeOnCancel doc = new DisposeOnCancel(d);
assertFalse(doc.cancel(true));
Reported by PMD.
Line: 33
DisposeOnCancel doc = new DisposeOnCancel(d);
assertFalse(doc.cancel(true));
assertFalse(doc.isCancelled());
assertFalse(doc.isDone());
Reported by PMD.
Line: 35
assertFalse(doc.cancel(true));
assertFalse(doc.isCancelled());
assertFalse(doc.isDone());
assertNull(doc.get());
Reported by PMD.
Line: 37
assertFalse(doc.isCancelled());
assertFalse(doc.isDone());
assertNull(doc.get());
assertNull(doc.get(1, TimeUnit.SECONDS));
}
Reported by PMD.
Line: 39
assertFalse(doc.isDone());
assertNull(doc.get());
assertNull(doc.get(1, TimeUnit.SECONDS));
}
}
Reported by PMD.
Line: 41
assertNull(doc.get());
assertNull(doc.get(1, TimeUnit.SECONDS));
}
}
Reported by PMD.
Line: 16
package io.reactivex.rxjava3.internal.schedulers;
import static org.junit.Assert.*;
import java.util.concurrent.TimeUnit;
import org.junit.Test;
Reported by PMD.
Line: 23
import org.junit.Test;
import io.reactivex.rxjava3.core.RxJavaTest;
import io.reactivex.rxjava3.disposables.*;
public class DisposeOnCancelTest extends RxJavaTest {
@Test
public void basicCoverage() throws Exception {
Reported by PMD.
src/main/java/io/reactivex/rxjava3/internal/operators/completable/CompletableDoOnEvent.java
8 issues
Line: 56
}
@Override
public void onError(Throwable e) {
try {
onEvent.accept(e);
} catch (Throwable ex) {
Exceptions.throwIfFatal(ex);
e = new CompositeException(e, ex);
Reported by PMD.
Line: 22
import io.reactivex.rxjava3.functions.Consumer;
public final class CompletableDoOnEvent extends Completable {
final CompletableSource source;
final Consumer<? super Throwable> onEvent;
public CompletableDoOnEvent(final CompletableSource source, final Consumer<? super Throwable> onEvent) {
this.source = source;
this.onEvent = onEvent;
Reported by PMD.
Line: 23
public final class CompletableDoOnEvent extends Completable {
final CompletableSource source;
final Consumer<? super Throwable> onEvent;
public CompletableDoOnEvent(final CompletableSource source, final Consumer<? super Throwable> onEvent) {
this.source = source;
this.onEvent = onEvent;
}
Reported by PMD.
Line: 36
}
final class DoOnEvent implements CompletableObserver {
private final CompletableObserver observer;
DoOnEvent(CompletableObserver observer) {
this.observer = observer;
}
Reported by PMD.
Line: 46
public void onComplete() {
try {
onEvent.accept(null);
} catch (Throwable e) {
Exceptions.throwIfFatal(e);
observer.onError(e);
return;
}
Reported by PMD.
Line: 59
public void onError(Throwable e) {
try {
onEvent.accept(e);
} catch (Throwable ex) {
Exceptions.throwIfFatal(ex);
e = new CompositeException(e, ex);
}
observer.onError(e);
Reported by PMD.
Line: 16
package io.reactivex.rxjava3.internal.operators.completable;
import io.reactivex.rxjava3.core.*;
import io.reactivex.rxjava3.disposables.Disposable;
import io.reactivex.rxjava3.exceptions.*;
import io.reactivex.rxjava3.functions.Consumer;
public final class CompletableDoOnEvent extends Completable {
Reported by PMD.
Line: 18
import io.reactivex.rxjava3.core.*;
import io.reactivex.rxjava3.disposables.Disposable;
import io.reactivex.rxjava3.exceptions.*;
import io.reactivex.rxjava3.functions.Consumer;
public final class CompletableDoOnEvent extends Completable {
final CompletableSource source;
final Consumer<? super Throwable> onEvent;
Reported by PMD.
src/main/java/io/reactivex/rxjava3/internal/util/MergerBiFunction.java
8 issues
Line: 24
* A BiFunction that merges two Lists into a new list.
* @param <T> the value type
*/
public final class MergerBiFunction<T> implements BiFunction<List<T>, List<T>, List<T>> {
final Comparator<? super T> comparator;
public MergerBiFunction(Comparator<? super T> comparator) {
this.comparator = comparator;
Reported by PMD.
Line: 24
* A BiFunction that merges two Lists into a new list.
* @param <T> the value type
*/
public final class MergerBiFunction<T> implements BiFunction<List<T>, List<T>, List<T>> {
final Comparator<? super T> comparator;
public MergerBiFunction(Comparator<? super T> comparator) {
this.comparator = comparator;
Reported by PMD.
Line: 26
*/
public final class MergerBiFunction<T> implements BiFunction<List<T>, List<T>, List<T>> {
final Comparator<? super T> comparator;
public MergerBiFunction(Comparator<? super T> comparator) {
this.comparator = comparator;
}
Reported by PMD.
Line: 33
}
@Override
public List<T> apply(List<T> a, List<T> b) {
int n = a.size() + b.size();
if (n == 0) {
return new ArrayList<>();
}
List<T> both = new ArrayList<>(n);
Reported by PMD.
Line: 33
}
@Override
public List<T> apply(List<T> a, List<T> b) {
int n = a.size() + b.size();
if (n == 0) {
return new ArrayList<>();
}
List<T> both = new ArrayList<>(n);
Reported by PMD.
Line: 33
}
@Override
public List<T> apply(List<T> a, List<T> b) {
int n = a.size() + b.size();
if (n == 0) {
return new ArrayList<>();
}
List<T> both = new ArrayList<>(n);
Reported by PMD.
Line: 49
while (s1 != null && s2 != null) {
if (comparator.compare(s1, s2) < 0) { // s1 comes before s2
both.add(s1);
s1 = at.hasNext() ? at.next() : null;
} else {
both.add(s2);
s2 = bt.hasNext() ? bt.next() : null;
}
}
Reported by PMD.
Line: 52
s1 = at.hasNext() ? at.next() : null;
} else {
both.add(s2);
s2 = bt.hasNext() ? bt.next() : null;
}
}
if (s1 != null) {
both.add(s1);
Reported by PMD.
src/main/java/io/reactivex/rxjava3/internal/operators/maybe/MaybeOnErrorReturn.java
8 issues
Line: 30
*/
public final class MaybeOnErrorReturn<T> extends AbstractMaybeWithUpstream<T, T> {
final Function<? super Throwable, ? extends T> itemSupplier;
public MaybeOnErrorReturn(MaybeSource<T> source,
Function<? super Throwable, ? extends T> itemSupplier) {
super(source);
this.itemSupplier = itemSupplier;
Reported by PMD.
Line: 45
static final class OnErrorReturnMaybeObserver<T> implements MaybeObserver<T>, Disposable {
final MaybeObserver<? super T> downstream;
final Function<? super Throwable, ? extends T> itemSupplier;
Disposable upstream;
Reported by PMD.
Line: 47
final MaybeObserver<? super T> downstream;
final Function<? super Throwable, ? extends T> itemSupplier;
Disposable upstream;
OnErrorReturnMaybeObserver(MaybeObserver<? super T> actual,
Function<? super Throwable, ? extends T> valueSupplier) {
Reported by PMD.
Line: 49
final Function<? super Throwable, ? extends T> itemSupplier;
Disposable upstream;
OnErrorReturnMaybeObserver(MaybeObserver<? super T> actual,
Function<? super Throwable, ? extends T> valueSupplier) {
this.downstream = actual;
this.itemSupplier = valueSupplier;
Reported by PMD.
Line: 87
try {
v = Objects.requireNonNull(itemSupplier.apply(e), "The itemSupplier returned a null value");
} catch (Throwable ex) {
Exceptions.throwIfFatal(ex);
downstream.onError(new CompositeException(e, ex));
return;
}
Reported by PMD.
Line: 16
package io.reactivex.rxjava3.internal.operators.maybe;
import io.reactivex.rxjava3.core.*;
import io.reactivex.rxjava3.disposables.Disposable;
import io.reactivex.rxjava3.exceptions.*;
import io.reactivex.rxjava3.functions.Function;
import io.reactivex.rxjava3.internal.disposables.DisposableHelper;
Reported by PMD.
Line: 18
import io.reactivex.rxjava3.core.*;
import io.reactivex.rxjava3.disposables.Disposable;
import io.reactivex.rxjava3.exceptions.*;
import io.reactivex.rxjava3.functions.Function;
import io.reactivex.rxjava3.internal.disposables.DisposableHelper;
import java.util.Objects;
Reported by PMD.
Line: 86
T v;
try {
v = Objects.requireNonNull(itemSupplier.apply(e), "The itemSupplier returned a null value");
} catch (Throwable ex) {
Exceptions.throwIfFatal(ex);
downstream.onError(new CompositeException(e, ex));
return;
}
Reported by PMD.
src/main/java/io/reactivex/rxjava3/internal/operators/single/SingleDoAfterTerminate.java
8 issues
Line: 31
*/
public final class SingleDoAfterTerminate<T> extends Single<T> {
final SingleSource<T> source;
final Action onAfterTerminate;
public SingleDoAfterTerminate(SingleSource<T> source, Action onAfterTerminate) {
this.source = source;
Reported by PMD.
Line: 33
final SingleSource<T> source;
final Action onAfterTerminate;
public SingleDoAfterTerminate(SingleSource<T> source, Action onAfterTerminate) {
this.source = source;
this.onAfterTerminate = onAfterTerminate;
}
Reported by PMD.
Line: 47
static final class DoAfterTerminateObserver<T> implements SingleObserver<T>, Disposable {
final SingleObserver<? super T> downstream;
final Action onAfterTerminate;
Disposable upstream;
Reported by PMD.
Line: 49
final SingleObserver<? super T> downstream;
final Action onAfterTerminate;
Disposable upstream;
DoAfterTerminateObserver(SingleObserver<? super T> actual, Action onAfterTerminate) {
this.downstream = actual;
Reported by PMD.
Line: 49
final SingleObserver<? super T> downstream;
final Action onAfterTerminate;
Disposable upstream;
DoAfterTerminateObserver(SingleObserver<? super T> actual, Action onAfterTerminate) {
this.downstream = actual;
Reported by PMD.
Line: 51
final Action onAfterTerminate;
Disposable upstream;
DoAfterTerminateObserver(SingleObserver<? super T> actual, Action onAfterTerminate) {
this.downstream = actual;
this.onAfterTerminate = onAfterTerminate;
}
Reported by PMD.
Line: 94
private void onAfterTerminate() {
try {
onAfterTerminate.run();
} catch (Throwable ex) {
Exceptions.throwIfFatal(ex);
RxJavaPlugins.onError(ex);
}
}
}
Reported by PMD.
Line: 16
package io.reactivex.rxjava3.internal.operators.single;
import io.reactivex.rxjava3.core.*;
import io.reactivex.rxjava3.disposables.Disposable;
import io.reactivex.rxjava3.exceptions.Exceptions;
import io.reactivex.rxjava3.functions.Action;
import io.reactivex.rxjava3.internal.disposables.DisposableHelper;
import io.reactivex.rxjava3.plugins.RxJavaPlugins;
Reported by PMD.