I want to ask if it's safe not to close an environment?
final PersistentEntityStore entityStore = manager.getPersistentEntityStore(xodusRoot, instance);
final List<User> users = new LinkedList<>();
try {
} finally {
//entityStore.close
}
The reason behind not closing the environment is that this example code here is used in a Servlet environment in which we implemented a sort of Sigleton lookup table (map) to hold the Environments and EntiyStores and if we close it the next HTTP POST request will get a "Environment already closed" error, thus we don't close it.
And the reason we implemented the Lookup table (map) here is to prevent the servlet requests from getting Database lock issues, especially on multiple concurrent requests.
Is this safe to do? Or is this even the correct approach?