vavr-io/vavr

Strange behaviour, maybe an error when using peek on Android 5.1.1

Open

#2761 opened on Apr 3, 2024

View on GitHub
 (2 comments) (0 reactions) (0 assignees)Java (5,390 stars) (605 forks)batch import
help wanted

Description

The following code runs fine on newer Android versions. However, I've encountered an issue on Android 5.1.1.

After an HTTP request is returned, attempting to use peek to retrieve either the data or an error response results in unexpected behavior.

My request looks like this:

public Either<Failure, Authenticated> executeRequest(Params params) {
// return Failure or Authenticated
}

I expect the result to be received in my view model. Here's a simplified example of the expected behavior:

myUseCase.execute(signIn).peek(
   failure -> {},
   result -> {}
);

Neither the failure nor the success callback is triggered in the view model. However, I observed the following log message:

Rejecting re-init on previously-failed class java.lang.Class<io.vavr.control.Either$$ExternalSyntheticLambda0>
Rejecting re-init on previously-failed class java.lang.Class<io.vavr.control.Either$$ExternalSyntheticLambda0>
Rejecting re-init on previously-failed class java.lang.Class<io.vavr.control.Either$$ExternalSyntheticLambda1>
Rejecting re-init on previously-failed class java.lang.Class<io.vavr.control.Either$$ExternalSyntheticLambda1>
Rejecting re-init on previously-failed class java.lang.Class<io.vavr.control.Either$$ExternalSyntheticLambda2>
Rejecting re-init on previously-failed class java.lang.Class<io.vavr.control.Either$$ExternalSyntheticLambda2>
Rejecting re-init on previously-failed class java.lang.Class<io.vavr.Function1>
Rejecting re-init on previously-failed class java.lang.Class<io.vavr.Function1>
Rejecting re-init on previously-failed class java.lang.Class<io.vavr.PartialFunction>
Rejecting re-init on previously-failed class java.lang.Class<io.vavr.PartialFunction>
Rejecting re-init on previously-failed class java.lang.Class<io.vavr.collection.Seq>
Rejecting re-init on previously-failed class java.lang.Class<io.vavr.collection.Seq>
Rejecting re-init on previously-failed class java.lang.Class<io.vavr.collection.IndexedSeq>
Rejecting re-init on previously-failed class java.lang.Class<io.vavr.collection.IndexedSeq>
Rejecting re-init on previously-failed class java.lang.Class<io.vavr.collection.Vector>
Rejecting re-init on previously-failed class java.lang.Class<io.vavr.collection.Vector>
Rejecting re-init on previously-failed class java.lang.Class<io.vavr.collection.IndexedSeq>
Rejecting re-init on previously-failed class java.lang.Class<io.vavr.collection.Array>
Rejecting re-init on previously-failed class java.lang.Class<io.vavr.collection.Array>
Rejecting re-init on previously-failed class java.lang.Class<io.vavr.collection.Array>
Rejecting re-init on previously-failed class java.lang.Class<io.vavr.collection.IndexedSeq>
Rejecting re-init on previously-failed class java.lang.Class<io.vavr.collection.CharSeq>
Rejecting re-init on previously-failed class java.lang.Class<io.vavr.collection.CharSeq>
Rejecting re-init on previously-failed class java.lang.Class<io.vavr.collection.CharSeq>
Rejecting re-init on previously-failed class java.lang.Class<io.vavr.PartialFunction>
Rejecting re-init on previously-failed class java.lang.Class<io.vavr.collection.Map>
Rejecting re-init on previously-failed class java.lang.Class<io.vavr.collection.Map>
Rejecting re-init on previously-failed class java.lang.Class<io.vavr.collection.Map>
Rejecting re-init on previously-failed class java.lang.Class<io.vavr.collection.Map>
Rejecting re-init on previously-failed class java.lang.Class<io.vavr.collection.Map>
Rejecting re-init on previously-failed class java.lang.Class<io.vavr.collection.Seq>
Rejecting re-init on previously-failed class java.lang.Class<io.vavr.collection.LinearSeq>
Rejecting re-init on previously-failed class java.lang.Class<io.vavr.collection.LinearSeq>
Rejecting re-init on previously-failed class java.lang.Class<io.vavr.collection.List>
Rejecting re-init on previously-failed class java.lang.Class<io.vavr.collection.List>
Rejecting re-init on previously-failed class java.lang.Class<io.vavr.collection.List>
Rejecting re-init on previously-failed class java.lang.Class<io.vavr.collection.Map>
Rejecting re-init on previously-failed class java.lang.Class<io.vavr.collection.Map>
Rejecting re-init on previously-failed class java.lang.Class<io.vavr.collection.Map>
Rejecting re-init on previously-failed class java.lang.Class<io.vavr.collection.Map>
Rejecting re-init on previously-failed class java.lang.Class<io.vavr.collection.LinearSeq>
Rejecting re-init on previously-failed class java.lang.Class<io.vavr.collection.Queue>
Rejecting re-init on previously-failed class java.lang.Class<io.vavr.collection.Queue>
Rejecting re-init on previously-failed class java.lang.Class<io.vavr.collection.Queue>
Rejecting re-init on previously-failed class java.lang.Class<io.vavr.collection.Map>
Rejecting re-init on previously-failed class java.lang.Class<io.vavr.collection.SortedMap>
Rejecting re-init on previously-failed class java.lang.Class<io.vavr.collection.SortedMap>
Rejecting re-init on previously-failed class java.lang.Class<io.vavr.collection.SortedMap>
Rejecting re-init on previously-failed class java.lang.Class<io.vavr.collection.SortedMap>
Rejecting re-init on previously-failed class java.lang.Class<io.vavr.collection.SortedMap>
Rejecting re-init on previously-failed class java.lang.Class<io.vavr.collection.SortedMap>
Rejecting re-init on previously-failed class java.lang.Class<io.vavr.collection.SortedMap>
Rejecting re-init on previously-failed class java.lang.Class<io.vavr.collection.SortedMap>
Rejecting re-init on previously-failed class java.lang.Class<io.vavr.collection.SortedMap>
Rejecting re-init on previously-failed class java.lang.Class<io.vavr.collection.LinearSeq>
Rejecting re-init on previously-failed class java.lang.Class<io.vavr.collection.Stream>
Rejecting re-init on previously-failed class java.lang.Class<io.vavr.collection.Stream>
Rejecting re-init on previously-failed class java.lang.Class<io.vavr.collection.Stream>
Rejecting re-init on previously-failed class java.lang.Class<io.vavr.collection.List>
Rejecting re-init on previously-failed class java.lang.Class<io.vavr.collection.List>
Rejecting re-init on previously-failed class java.lang.Class<io.vavr.collection.Vector>
Rejecting re-init on previously-failed class java.lang.Class<io.vavr.collection.Vector>
Rejecting re-init on previously-failed class java.lang.Class<com.mypackage.myapp.fragments.LoginFragmentViewModel$$ExternalSyntheticLambda1>

If I rewrite this using the following, it works:

Either<Failure, Authenticated> result = myUseCase.execute(signIn);

if(result.isLeft()) {
   Failure failure = result.getLeft();
} else {
   Authenticated authenticated = result.get();
}

Contributor guide