vlingo / xoom-symbio-jdbc

The VLINGO XOOM SYMBIO implementation for JDBC for Reactive storage using Event-Sourcing, Key-Value, and Object storage.
https://vlingo.io
Mozilla Public License 2.0
4 stars 12 forks source link

NullPointer in PostgresJournalActor in case of errors #7

Closed sturmm closed 5 years ago

sturmm commented 5 years ago

I tried to implement an example with vlingo eventsourcing and took the table definition from the documentation first (which is outdatet). With that old schema I got NullPointerExceptions from the exception handlers in PostgresJournalActor which had hidden real the error message e.g. 'table vlingo_symbio_journal not found'.

This is one of the exception handlers from the appendWith method:

 final Consumer<Exception> whenFailed =
(e) -> interest.appendResultedIn(Failure.of(new StorageException(Result.Failure, e.getMessage(), e)), streamName, streamVersion, source, Optional.of(snapshot), object);

I assume that the snapshotparameter could be null?! In this case Optional.of(...) needs to be replaced with Optional.ofNullable(...) as Optional.of(...) in java works different than in scala and throws NPE if null is passed as parameter.

VaughnVernon commented 5 years ago

@RoadRunner120485 The following commits fix this issue and provide a test:

https://github.com/vlingo/vlingo-symbio-jdbc/commit/c0ab355eb16943c68574af6dc4123a8b52680073 https://github.com/vlingo/vlingo-symbio-jdbc/commit/2b0d189be16d769dcad464e96a888cd7624056a1 https://github.com/vlingo/vlingo-symbio-jdbc/commit/526a51e3afa2fb1d11ef4e694128860dced0f60c#diff-8f0f5a073c811558f1c9e17dd60be2bfR131

Please ignore the file deletions as we have some test database scripts not being cleaned up.

Note that it is difficult to test the incorrect database definition. Could you please point to where the documentation is wrong? This will be fixed next.

Please test and close if you agree.

VaughnVernon commented 5 years ago

@RoadRunner120485 One other comment. Actually there are two method signatures for each of appendWith() and appendAllWith(). One method signature provides no means to persist a snapshot and the other does. Technically you should always pass a valid snapshot parameter when using the snapshot-capable methods. Passing a null is now handled with a graceful failure, so the issue of passing null is fixed.

VaughnVernon commented 5 years ago

@kmruiz Could you please update the following documentation so that it has the current/valid table definitions for Postgres? Per @RoadRunner120485 the table definition(s) are outdated. It would be good to have table definitions for both events and snapshots in the docs.

https://docs.vlingo.io/vlingo-symbio/developing-event-sourced-models

kmruiz commented 5 years ago

Documentation up-to-date now (didn't realise the schema changed, sorry for the inconvenience!).

Thanks for your help!

sturmm commented 5 years ago

Works now. Thank you.