Skip to content

Additional check if child session has already been closed. #470

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

Conversation

itmagination
Copy link
Contributor

This simple fix prevents unnecessary SessionException("Session was already closed") throw when both parent session and child session are closed separately (order does not matter). Before invoking close on child session (during parent session close) we should check if child session has not been closed already. Unfortunately to check if session was closed we have to use SessionImpl class instead of ISession interface, so we changed SessionImpl’s childSessionsByEntityMode private field type IDictionary<EntityMode, ISession> into IDictionary<EntityMode, SessionImpl>.

@hazzik
Copy link
Member

hazzik commented Jun 9, 2016

Please use ISessionImplementor instead of SessionImpl

…ssionImpl instead of SessionImpl type itself. Additional necessary changes were made in ISessionImplementor interface and dependent types.
@itmagination
Copy link
Contributor Author

I used ISessionImplementor instead of SessionImpl as requested. Unfortunately I had to add Close method in ISessionImplementor interface and make other necessary changes in dependent types (add abstract Close method in AbstractSessionImpl etc.). In GetSession method of SessionImpl class I had to cast result to ISession interface, because there is no formal connection between ISession and ISessionImplementator interfaces.

@hazzik
Copy link
Member

hazzik commented Dec 1, 2016

Hi @itmagination.

There is ISession.IsOpen property which implementation is exactly !IsClosed, so, this change shall be only one line:

if (pair.Value.IsOpen)
{
     pair.Value.Close();
}

No other changes are required.

@itmagination
Copy link
Contributor Author

Oh my! You're right! I've closed this knotty PR and opened a new one #542 containing this simple fix. Thank you!

@itmagination itmagination deleted the check_if_child_session_has_already_been_closed branch December 7, 2016 10:02
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 this pull request may close these issues.

2 participants