EventStore / EventStoreDB-Client-Java

Official Asynchronous Java 8+ Client Library for EventStoreDB 20.6+
https://eventstore.com
Apache License 2.0
63 stars 19 forks source link

Reactive stream reads might call onError twice #190

Closed dpasek-senacor closed 1 year ago

dpasek-senacor commented 2 years ago

If a read operation of a stream causes an exception the onError() method of a reactive subscriber might be called twice. This is not allowed according to the reactive spec. . This is not a problem for the non-reactive API as the second onError() call is ignored by the ReadSuscriber used in the EventStoreDBClient. When using the reactive API this might be a problem in certain conditions: framework like RxJava will unsubscribe after the first onError() call. The second error cannot be handled and will be delegated to the default error handler. For RxJava this will internally usually call the UncaughtExceptionHandler of the current thread. Depending of the context this might be ignored but in certain contexts this might break something. In our scenario it have been some tests.

I will provide an pull request for this as everything to fix it is already in place.