{"action":"created","issue":{"url":"https://api.github.com/repos/igniterealtime/Openfire/issues/374","labels_url":"https://api.github.com/repos/igniterealtime/Openfire/issues/374/labels{/name}","comments_url":"https://api.github.com/repos/igniterealtime/Openfire/issues/374/comments","events_url":"https://api.github.com/repos/igniterealtime/Openfire/issues/374/events","html_url":"https://github.com/igniterealtime/Openfire/pull/374","id":116870736,"number":374,"title":"OF-881: Simplify connection close semantics","user":{"login":"tevans","id":826423,"avatar_url":"https://avatars.githubusercontent.com/u/826423?v=3","gravatar_id":"","url":"https://api.github.com/users/tevans","html_url":"https://github.com/tevans","followers_url":"https://api.github.com/users/tevans/followers","following_url":"https://api.github.com/users/tevans/following{/other_user}","gists_url":"https://api.github.com/users/tevans/gists{/gist_id}","starred_url":"https://api.github.com/users/tevans/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tevans/subscriptions","organizations_url":"https://api.github.com/users/tevans/orgs","repos_url":"https://api.github.com/users/tevans/repos","events_url":"https://api.github.com/users/tevans/events{/privacy}","received_events_url":"https://api.github.com/users/tevans/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":3,"created_at":"2015-11-13T23:01:23Z","updated_at":"2015-11-14T12:38:10Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/igniterealtime/Openfire/pulls/374","html_url":"https://github.com/igniterealtime/Openfire/pull/374","diff_url":"https://github.com/igniterealtime/Openfire/pull/374.diff","patch_url":"https://github.com/igniterealtime/Openfire/pull/374.patch"},"body":"Avoid recursion and synchronization issues"},"comment":{"url":"https://api.github.com/repos/igniterealtime/Openfire/issues/comments/156693252","html_url":"https://github.com/igniterealtime/Openfire/pull/374#issuecomment-156693252","issue_url":"https://api.github.com/repos/igniterealtime/Openfire/issues/374","id":156693252,"user":{"login":"sco0ter","id":7206462,"avatar_url":"https://avatars.githubusercontent.com/u/7206462?v=3","gravatar_id":"","url":"https://api.github.com/users/sco0ter","html_url":"https://github.com/sco0ter","followers_url":"https://api.github.com/users/sco0ter/followers","following_url":"https://api.github.com/users/sco0ter/following{/other_user}","gists_url":"https://api.github.com/users/sco0ter/gists{/gist_id}","starred_url":"https://api.github.com/users/sco0ter/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sco0ter/subscriptions","organizations_url":"https://api.github.com/users/sco0ter/orgs","repos_url":"https://api.github.com/users/sco0ter/repos","events_url":"https://api.github.com/users/sco0ter/events{/privacy}","received_events_url":"https://api.github.com/users/sco0ter/received_events","type":"User","site_admin":false},"created_at":"2015-11-14T12:38:10Z","updated_at":"2015-11-14T12:38:10Z","body":"Some random thoughts on this:\r\n- I wonder if we could use a `AtomicReference<State> state` to get rid of the synchronized blocks, something like:\r\n```java\r\n                if (!state.compareAndSet(State.RUNNING, State.CLOSING)) {\r\n                    return;\r\n                }\r\n```\r\n- Having both `Session.STATUS_CLOSED` and `State.CLOSED` is confusing, isn't it?\r\n- We should consider implementing `java.lang.AutoCloseable`... just because.\r\n- The implemented behavior is called `idempotent` (closing a closed resource has no effect). Maybe it should be clear in the JavaDoc.\r\n- It looks well otherwise. I think it works, `close()` should only run once, therfore no recursion, no deadlocks."}}