Github user pingtimeout commented on the pull request:
https://github.com/apache/incubator-tinkerpop/pull/146#issuecomment-157756815
I am not an expert in the Tinkerpop codebase but my understanding of the
code is the following:
Yes, the `CompletableFuture` can be executed in parallel with other tasks
by the executor, since [it may
be](https://github.com/apache/incubator-tinkerpop/blob/master/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/Cluster.java#L580-580)
multithreaded. However, I don't think it can complete if tasks are still
being executed. It calls `factory.shutdown()` which [delegates the
action](https://github.com/apache/incubator-tinkerpop/blob/master/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/Cluster.java#L552-552)
to Netty.
That `factory.shutdown()` closes Netty's event loop after a grace delay of
roughly 17 seconds (that's the "sensible values" described by
`EventLoopGroup::shutdownGracefully()`. A long running task that uses the
transport layer may therefore encounter an IOException, but I don't think that
is a really bad thing, considering it is the user who explicitly triggered the
`cluster.close()` without waiting for all of the pending requests to complete.
I mean, as a developer, if my code is reading a file and I call
`inputStream.close()` in another thread, I don't expect the latter call to
block indefinitely until the whole file has been read.
In the alternative approach you describe, how long would you wait for the
termination to happen?
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---