From 1e3325adaa809319c45eee81951b9f14bd3ee6b6 Mon Sep 17 00:00:00 2001 From: Danny van Heumen Date: Sat, 26 Jul 2014 23:21:35 +0200 Subject: [PATCH] Fixed a case where the chat room members are cleaned out because the account is already disabled, but a handler is still acting on its final messages. --- .../impl/protocol/irc/IrcStack.java | 48 ++++++++++--------- 1 file changed, 25 insertions(+), 23 deletions(-) diff --git a/src/net/java/sip/communicator/impl/protocol/irc/IrcStack.java b/src/net/java/sip/communicator/impl/protocol/irc/IrcStack.java index 6c2cc125f..807db6968 100644 --- a/src/net/java/sip/communicator/impl/protocol/irc/IrcStack.java +++ b/src/net/java/sip/communicator/impl/protocol/irc/IrcStack.java @@ -1514,19 +1514,22 @@ public void onChannelPart(final ChanPartMessage msg) String userNick = msg.getSource().getNick(); ChatRoomMember member = this.chatroom.getChatRoomMember(userNick); - try - { - // Possibility that 'member' is null (should be fixed now - // that race condition in irc-api is fixed) - this.chatroom.fireMemberPresenceEvent(member, null, - ChatRoomMemberPresenceChangeEvent.MEMBER_LEFT, - msg.getPartMsg()); - } - catch (NullPointerException e) + if (member != null) { - LOGGER.warn( - "This should not have happened. Please report this " - + "as it is a bug.", e); + // When the account has been disabled, the chat room may return + // null. If that is NOT the case, continue handling. + try + { + this.chatroom.fireMemberPresenceEvent(member, null, + ChatRoomMemberPresenceChangeEvent.MEMBER_LEFT, + msg.getPartMsg()); + } + catch (NullPointerException e) + { + LOGGER.warn( + "This should not have happened. Please report this " + + "as it is a bug.", e); + } } } @@ -1738,12 +1741,11 @@ public void onChannelNotice(final ChannelNotice msg) */ private void leaveChatRoom() { - if (!IrcStack.this.isConnected()) + final IRCApi irc = IrcStack.this.session.get(); + if (irc != null) { - return; + irc.deleteListener(this); } - final IRCApi irc = IrcStack.this.session.get(); - irc.deleteListener(this); IrcStack.this.joined.remove(this.chatroom.getIdentifier()); IrcStack.this.provider.getMUC().fireLocalUserPresenceEvent( this.chatroom, @@ -1954,10 +1956,7 @@ private boolean isThisChatRoom(final String chatRoomName) */ private boolean isMe(final IRCUser user) { - // FIXME in case of disconnected, connectionState == null, so - // results in NPE. - return IrcStack.this.connectionState.getNickname().equals( - user.getNick()); + return isMe(user.getNick()); } /** @@ -1968,9 +1967,12 @@ private boolean isMe(final IRCUser user) */ private boolean isMe(final String name) { - // FIXME in case of disconnected, connectionState == null, so - // results in NPE. - return IrcStack.this.connectionState.getNickname().equals(name); + String userNick = IrcStack.this.getActiveNick(); + if (userNick == null) + { + return false; + } + return userNick.equals(name); } }