google / agera

Reactive Programming for Android
Apache License 2.0
7.2k stars 639 forks source link

crash bug #161

Closed xupeixuan closed 6 years ago

xupeixuan commented 7 years ago

SqlDatabaseFunctions class should add catch IllegalStateException when do merge operator. this will happen "java.lang.IllegalStateException: Cannot perform this operation because the connection pool has been closed." thx.

ghost commented 6 years ago

Hi @xupeixuan, Is this issue still open?

maxtroy commented 6 years ago

Apologies to keep this issue open for so long.

The database extension is just a sample extension for translating common database operations to Functions and Suppliers for use by other parts of Agera (mainly the Repositories). The database is supposed to have come from a SqlDatabaseSupplier, also available from the same extension, which is an SqlOpenHelper and does not automatically close the database connection, and therefore the IllegalStateException you mentioned should be unreachable, unless your code manually closes the connection. Then, because the SqlDatabaseSupplier is itself the SqlOpenHelper, closing the database means the end-of-life of the SqlDatabaseSupplier, and therefore any Function created with SqlDatabaseFunctions class, which permanently holds onto the (now dead) SqlDatabaseSupplier, should no longer be used.

If you want to be able to close the database connection and keep using the same Supplier instance to automatically reopen the database for more operations, consider building a custom class.

Hope this helps!

xupeixuan commented 6 years ago

ok,thanks.