Skip to content

Exception thrown from "executor.disconnect()" leads to CommunicationProtocol remaining open #399

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wajda opened this issue Jun 28, 2021 · 2 comments · Fixed by #400
Closed
Assignees

Comments

@wajda
Copy link
Contributor

wajda commented Jun 28, 2021

@Override
    public void shutdown() throws ArangoDBException {
        try {
            executor.disconnect();
            cp.close(); // <---- This is not called when the previous method throws an exception !!!
        } catch (final IOException e) {
            throw new ArangoDBException(e);
        }
    }

When an exception is thrown from the executor.disconnect() (for instance 401 - unauthorized) the CommunicationProtocol.close() isn't called and thus all the associated with it resources (apparently including thread pools or such) remain unclosed. This leads to the client app being unable to exit normally.

AN easy workaround is to call shutdown() in a try-catch block and repeat the call on ArangoDBException like this:

    try {
      arango.shutdown()
    } catch {
      case _: ArangoDBException =>
        arango.shutdown()
    }

It would be good however, to handle exceptions internally in the driver and do a proper cleanup.

@rashtao
Copy link
Collaborator

rashtao commented Jun 29, 2021

Hi @wajda , thanks for spotting this. I created #400 which improves the safety of the shutdown task. Does it solve your case?

@wajda
Copy link
Contributor Author

wajda commented Jun 29, 2021

Yes, now it works as expected. Thank you very much!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants