From d2b2106f4c1ae5850836ffd885a51520bf61e1e3 Mon Sep 17 00:00:00 2001 From: Brian Clements Date: Tue, 22 Apr 2014 12:34:30 -0500 Subject: [PATCH] Issue #2903 added connection tests to session close methods fixes illegal state exception problem when booted from xmpp server Former-commit-id: f9ab4f9cfe6d5901f871e6a4d2bebd6bfbd22237 [formerly 50f3f420eb2a2ad77b3672bb683fe62b8434e986] [formerly f9ab4f9cfe6d5901f871e6a4d2bebd6bfbd22237 [formerly 50f3f420eb2a2ad77b3672bb683fe62b8434e986] [formerly 49f86e4153410d32595eafa62cba68a46d880f97 [formerly d570c81caed35576e867df15c2a8d900135fef5f]]] Former-commit-id: 49f86e4153410d32595eafa62cba68a46d880f97 Former-commit-id: 9ef018dbe8c2cbcc6043a59a217c2831cb0f7284 [formerly c9453a244095996c91ebedc1284a49bc0a0c0ce6] Former-commit-id: 9ea5430774b8c78aabe76f315c6b77f695c31ff0 --- .../session/SharedDisplaySession.java | 30 +++++++++++-------- .../comm/provider/session/VenueSession.java | 6 +++- 2 files changed, 22 insertions(+), 14 deletions(-) diff --git a/cave/com.raytheon.uf.viz.collaboration.comm/src/com/raytheon/uf/viz/collaboration/comm/provider/session/SharedDisplaySession.java b/cave/com.raytheon.uf.viz.collaboration.comm/src/com/raytheon/uf/viz/collaboration/comm/provider/session/SharedDisplaySession.java index 5435e5b37d..e03cfa34c6 100644 --- a/cave/com.raytheon.uf.viz.collaboration.comm/src/com/raytheon/uf/viz/collaboration/comm/provider/session/SharedDisplaySession.java +++ b/cave/com.raytheon.uf.viz.collaboration.comm/src/com/raytheon/uf/viz/collaboration/comm/provider/session/SharedDisplaySession.java @@ -98,6 +98,7 @@ import com.raytheon.uf.viz.collaboration.comm.provider.user.VenueParticipant; * Mar 31, 2014 2899 mpduff Improve error messages. * Apr 15, 2014 2822 bclement added check for other participants being subscribed to topic * Apr 21, 2014 2822 bclement removed use of resources in topicSubscribers, added skipCache + * Apr 22, 2014 2903 bclement added connection test to closePubSub() method * * * @@ -511,21 +512,24 @@ public class SharedDisplaySession extends VenueSession implements closePubSub(); } + /** + * clean up pub sub subscription and objects + */ private void closePubSub() { try { - if (pubsubMgr == null || topic == null || !topicExists()) { - return; - } - Subscription sub = findSubscription(getAccount()); - if (sub == null) { - return; - } - topic.unsubscribe(sub.getJid(), sub.getId()); - topic.removeItemDeleteListener(this); - topic.removeItemEventListener(this); - if (hasRole(SharedDisplayRole.SESSION_LEADER)) { - cleanUpHttpStorage(topic.getId()); - pubsubMgr.deleteNode(topic.getId()); + if (conn != null && conn.isConnected() && pubsubMgr != null + && topic != null && topicExists()) { + Subscription sub = findSubscription(getAccount()); + if (sub == null) { + return; + } + topic.unsubscribe(sub.getJid(), sub.getId()); + topic.removeItemDeleteListener(this); + topic.removeItemEventListener(this); + if (hasRole(SharedDisplayRole.SESSION_LEADER)) { + cleanUpHttpStorage(topic.getId()); + pubsubMgr.deleteNode(topic.getId()); + } } topic = null; pubsubMgr = null; diff --git a/cave/com.raytheon.uf.viz.collaboration.comm/src/com/raytheon/uf/viz/collaboration/comm/provider/session/VenueSession.java b/cave/com.raytheon.uf.viz.collaboration.comm/src/com/raytheon/uf/viz/collaboration/comm/provider/session/VenueSession.java index 063232ae32..59d4724ec5 100644 --- a/cave/com.raytheon.uf.viz.collaboration.comm/src/com/raytheon/uf/viz/collaboration/comm/provider/session/VenueSession.java +++ b/cave/com.raytheon.uf.viz.collaboration.comm/src/com/raytheon/uf/viz/collaboration/comm/provider/session/VenueSession.java @@ -109,6 +109,7 @@ import com.raytheon.uf.viz.collaboration.comm.provider.user.VenueParticipant; * Apr 11, 2014 2903 bclement made constructor public b/c connection code moved packages * Apr 16, 2014 3020 bclement added check for invited rooms in roomExistsOnServer() * Apr 21, 2014 2822 bclement added hasMultipleHandles() + * Apr 22, 2014 2903 bclement added connection test to close method * * * @@ -192,7 +193,10 @@ public class VenueSession extends BaseSession implements IVenueSession { muc.removeParticipantListener(participantListener); participantListener = null; } - muc.leave(); + CollaborationConnection conn = getConnection(); + if (conn != null && conn.isConnected()) { + muc.leave(); + } muc = null; }