We're updating the issue view to help you get more done. 

Non-Idempotency of SharedSessionContract.close

Description

StatelessSession and Session both implement java.io.Closeabe, but their implementation is not idempotent according to Javadoc.

Javadoc: https://docs.oracle.com/javase/7/docs/api/java/io/Closeable.html#close()

1 Closes this stream and releases any system resources associated with it. If the stream is already closed then invoking this method has no effect.

SessionImpl line 311:

1 2 if (this.isClosed()) { throw new SessionException("Session was already closed");

The above is not compliant with java.io.Closeable contract.
Request is to do nothing if session is already close or to consistently expose isClosed() method to Session and StatelessSession. Currently isClosed() is a method of SessionImplementor, to which I must cast my session.

I have library code that tries to close session multiple times to ensure the developer did not forget to close the session in the outer-most object. And also calls to close() from finalizers to make 100% sure

Environment

None

Status

Assignee

Unassigned

Reporter

Antonio Anzivino

Fix versions

None

Labels

backPortable

Backport?

Suitable for new contributors

Yes, likely

Requires Release Note

None

Pull Request

None

backportDecision

None

Components

Affects versions

5.1.10

Priority

Minor