neo4j / neo4j-go-driver

Neo4j Bolt Driver for Go
Apache License 2.0
496 stars 70 forks source link

Session is still usable after Close. #568

Closed oleriajm closed 9 months ago

oleriajm commented 9 months ago

The Session must not be usable after the caller closed it explicitly.

Following pattern just works at the moment

    session := driver.NewSession(ctx, sessionConfig)
        session.Close()

        session.ExecuteRead(...)
        // and keep using session with more operations...

This is because Closing session cleans up pool/router etc, but all the references are still preserved.

As a good practice, the behavior should be fail-fast/fail-hard once you called Close on it

StephenCathcart commented 9 months ago

Hi @oleriajm

Thank you for taking the time to contribute to a Neo4j project, we appreciate all community engagement. Before we review a change we require that users have signed our Contributor License Agreement(CLA). This allows the "whitelist-check (pull-request)" part of our build process to pass. For more details on signing our CLA please see: https://neo4j.com/developer/cla/. Specifically the 'How to Sign' section.

StephenCathcart commented 9 months ago

Fixed by PR https://github.com/neo4j/neo4j-go-driver/pull/570, attempting to use a closed session now returns a usage error. Thank you @oleriajm for bringing this to our attention 👍.