speedment / jpa-streamer

JPAstreamer is a lightweight library for expressing JPA queries as Java Streams
GNU Lesser General Public License v2.1
339 stars 35 forks source link

resetStreamer() does not close the underlying Entity Manager #341

Closed julgus closed 1 year ago

julgus commented 1 year ago

Describe the bug Whenever resetting a Streamer using jpaStreamer.resetStreamer() the underlying Entity Manager is left open. This can cause memory leaks, see #147.

Expected behavior The Entity Manager associated with the removed Streamer should be closed, as we are no longer holding a reference to it. This also prevents JPAStreamer from properly closing these Entity Managers upon jpaStreamer.close() as they are no longer in the cache, but are still open.

Actual behavior Any Streamer that we cache will create an Entity Manager that stays open if the Streamer is removed from the cache through a call to jpaStreamer.resetStreamer().

JPAStreamer version e.g. JPAStreamer 3.0.1

julgus commented 1 year ago

Following discussions in #147, we decided to remove the cache altogether. Therefore resetStreamer() will be deprecated from 3.0.2.