Close all resources gracefully on JVM shutdown#98
Close all resources gracefully on JVM shutdown#98the123saurav wants to merge 2 commits intodevelopfrom
Conversation
| public void close() { | ||
| lock.lock(); | ||
| try { | ||
| chronicleMap.close(); |
There was a problem hiding this comment.
Hi @the123saurav, please consider this case https://github.com/OpenHFT/Chronicle-Map/blob/ea/docs/CM_Tutorial.adoc#close-chroniclemap
If you call close() too early before you have finished working with the map, this can cause your JVM to crash. Close MUST be the last thing that you do with the map.
So, although it is recommended that you close() when you have finished with the map, it is not something that you must do; it’s just something that we recommend you should do.
There was a problem hiding this comment.
Hmm good point. But does that stop us from calling this?
It will be called from 2 places:
- During JVM shutdown: In this case we are guranteed to not get any calls.
- User initiates shutdown in embedded mode. In this case we can just add to our doc, that this should be the last thing done to KevaServer.
I am also okay to remove this from shutdown procedure.
Kindly let me know.
There was a problem hiding this comment.
Sure @the123saurav, I think we can add that warning to our doc
|
Can this be merged now? @the123saurav |
1a702d1 to
dcff9ea
Compare
5ca77a9 to
b1c70d3
Compare
This change closes all resources(store, aof) on JVM shutdown.
It also introduces a notion of state in server and adds check on API methods to prevent misuse/race conditions.