Java - is calling Database.close() mandatory?


I have FDB client being used as part of certain tool executables. These tools are short lived and they just exit after doing their work. They do not call call Database.stop() before exiting.

Will this create any problems for FDB cluster? Would there be any resources (connections, buffers or any other state on FDB cluster) that would be leaked due to this pattern of access?

Are you referring to FDB.stopNetwork() ( Or perhaps Database.close()?

In either case, it should be safe for the process to let the process die without calling them. The former stops the network thread, which you could optionally choose to do if you didn’t need to use the FoundationDB client anymore. During a normal shutdown, there’s actually a shutdown hook that will stop the network for you as well (though again, it doesn’t hurt anything if the process dies without getting to stop the network).

For Database.close(), this just ensures that resources are released for the native object. Termination of the process accomplishes the same thing, so you don’t need to bother closing it when your process is ending if you don’t want to.

Yes I meant Database.close . Thanks for clarifying that!

No problem. I updated the title of the post for the benefit of anybody who comes across this or searches for it in the future.