{"action":"created","issue":{"url":"https://api.github.com/repos/OrchardCMS/Orchard/issues/6727","repository_url":"https://api.github.com/repos/OrchardCMS/Orchard","labels_url":"https://api.github.com/repos/OrchardCMS/Orchard/issues/6727/labels{/name}","comments_url":"https://api.github.com/repos/OrchardCMS/Orchard/issues/6727/comments","events_url":"https://api.github.com/repos/OrchardCMS/Orchard/issues/6727/events","html_url":"https://github.com/OrchardCMS/Orchard/pull/6727","id":146705486,"number":6727,"title":"#6722: Fix NullReferenceException in SessionLocator.DisposeSession()","user":{"login":"560889223","id":1115469,"avatar_url":"https://avatars.githubusercontent.com/u/1115469?v=3","gravatar_id":"","url":"https://api.github.com/users/560889223","html_url":"https://github.com/560889223","followers_url":"https://api.github.com/users/560889223/followers","following_url":"https://api.github.com/users/560889223/following{/other_user}","gists_url":"https://api.github.com/users/560889223/gists{/gist_id}","starred_url":"https://api.github.com/users/560889223/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/560889223/subscriptions","organizations_url":"https://api.github.com/users/560889223/orgs","repos_url":"https://api.github.com/users/560889223/repos","events_url":"https://api.github.com/users/560889223/events{/privacy}","received_events_url":"https://api.github.com/users/560889223/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/OrchardCMS/Orchard/labels/cla-not-required","name":"cla-not-required","color":"009800"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":3,"created_at":"2016-04-07T18:22:36Z","updated_at":"2016-04-11T20:15:09Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/OrchardCMS/Orchard/pulls/6727","html_url":"https://github.com/OrchardCMS/Orchard/pull/6727","diff_url":"https://github.com/OrchardCMS/Orchard/pull/6727.diff","patch_url":"https://github.com/OrchardCMS/Orchard/pull/6727.patch"},"body":"NREs are seen inside DisposeSession() during background task sweeping. By reviewing the code, it seems that this can happen if inside EnsureSession(), _session.BeginTransaction() fails due to DB issues (say DB connection pool maxing out), which leaves _session assigned but not _contentManagerSession."},"comment":{"url":"https://api.github.com/repos/OrchardCMS/Orchard/issues/comments/208540352","html_url":"https://github.com/OrchardCMS/Orchard/pull/6727#issuecomment-208540352","issue_url":"https://api.github.com/repos/OrchardCMS/Orchard/issues/6727","id":208540352,"user":{"login":"jtkech","id":8586360,"avatar_url":"https://avatars.githubusercontent.com/u/8586360?v=3","gravatar_id":"","url":"https://api.github.com/users/jtkech","html_url":"https://github.com/jtkech","followers_url":"https://api.github.com/users/jtkech/followers","following_url":"https://api.github.com/users/jtkech/following{/other_user}","gists_url":"https://api.github.com/users/jtkech/gists{/gist_id}","starred_url":"https://api.github.com/users/jtkech/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jtkech/subscriptions","organizations_url":"https://api.github.com/users/jtkech/orgs","repos_url":"https://api.github.com/users/jtkech/repos","events_url":"https://api.github.com/users/jtkech/events{/privacy}","received_events_url":"https://api.github.com/users/jtkech/received_events","type":"User","site_admin":false},"created_at":"2016-04-11T20:15:09Z","updated_at":"2016-04-11T20:15:09Z","body":"@sebastienros About your line note.\r\n\r\n> `DisposeSession()` would no be called, even if _session itself is not null.\r\n\r\nThis is already the case in the current implementation of `Cancel()`, if `_session` is not null but `_session.Transaction.IsActive` is false, then `DisposeSession()` is not called.\r\n\r\nSo, here, it's just to add a null check on `_session.Transaction` before testing `_session.Transaction.IsActive`.\r\n\r\nBut, do you mean that in this new use case, `_session` is not null and `_session.Transaction` is null, we have to call `DisposeSession()`?\r\n\r\nBest."}}