aboutsummaryrefslogtreecommitdiffstats
path: root/src/net
diff options
context:
space:
mode:
authorDamian Minkov <damencho@jitsi.org>2011-08-04 14:46:04 +0000
committerDamian Minkov <damencho@jitsi.org>2011-08-04 14:46:04 +0000
commit43ba2e126321f74c255ac33a7953aa9a013c8051 (patch)
treef510fce62bf190858b01fc3a131e304076f439ce /src/net
parente787d8b538da43b57d33e8e93cdf28d106b62822 (diff)
downloadjitsi-43ba2e126321f74c255ac33a7953aa9a013c8051.zip
jitsi-43ba2e126321f74c255ac33a7953aa9a013c8051.tar.gz
jitsi-43ba2e126321f74c255ac33a7953aa9a013c8051.tar.bz2
Fixes possible NPE calling getDisplayName on sip call peers that are already disconnected. Make sure media is closed even if any of call peer listeners throw an exception.
Diffstat (limited to 'src/net')
-rw-r--r--src/net/java/sip/communicator/impl/protocol/sip/CallPeerSipImpl.java6
-rw-r--r--src/net/java/sip/communicator/service/protocol/AbstractCallPeer.java38
-rw-r--r--src/net/java/sip/communicator/service/protocol/media/MediaAwareCallPeer.java16
3 files changed, 41 insertions, 19 deletions
diff --git a/src/net/java/sip/communicator/impl/protocol/sip/CallPeerSipImpl.java b/src/net/java/sip/communicator/impl/protocol/sip/CallPeerSipImpl.java
index 6110c38..75e17d4 100644
--- a/src/net/java/sip/communicator/impl/protocol/sip/CallPeerSipImpl.java
+++ b/src/net/java/sip/communicator/impl/protocol/sip/CallPeerSipImpl.java
@@ -322,6 +322,12 @@ public class CallPeerSipImpl
*/
public Contact getContact()
{
+ // if this peer has no call, most probably it means
+ // its disconnected and no more in call
+ // and we cannot obtain the contact
+ if(getCall() == null)
+ return null;
+
ProtocolProviderService pps = getCall().getProtocolProvider();
OperationSetPresenceSipImpl opSetPresence
= (OperationSetPresenceSipImpl) pps
diff --git a/src/net/java/sip/communicator/service/protocol/AbstractCallPeer.java b/src/net/java/sip/communicator/service/protocol/AbstractCallPeer.java
index 7fd3e52..5cd6885 100644
--- a/src/net/java/sip/communicator/service/protocol/AbstractCallPeer.java
+++ b/src/net/java/sip/communicator/service/protocol/AbstractCallPeer.java
@@ -245,22 +245,32 @@ public abstract class AbstractCallPeer<T extends Call,
{
CallPeerListener listener = listeners.next();
- if(eventType.equals(CallPeerChangeEvent
- .CALL_PEER_ADDRESS_CHANGE))
+ // catch any possible errors, so we are sure we dispatch events
+ // to all listeners
+ try
{
- listener.peerAddressChanged(evt);
- } else if(eventType.equals(CallPeerChangeEvent
- .CALL_PEER_DISPLAY_NAME_CHANGE))
- {
- listener.peerDisplayNameChanged(evt);
- } else if(eventType.equals(CallPeerChangeEvent
- .CALL_PEER_IMAGE_CHANGE))
- {
- listener.peerImageChanged(evt);
- } else if(eventType.equals(CallPeerChangeEvent
- .CALL_PEER_STATE_CHANGE))
+ if(eventType.equals(CallPeerChangeEvent
+ .CALL_PEER_ADDRESS_CHANGE))
+ {
+ listener.peerAddressChanged(evt);
+ } else if(eventType.equals(CallPeerChangeEvent
+ .CALL_PEER_DISPLAY_NAME_CHANGE))
+ {
+ listener.peerDisplayNameChanged(evt);
+ } else if(eventType.equals(CallPeerChangeEvent
+ .CALL_PEER_IMAGE_CHANGE))
+ {
+ listener.peerImageChanged(evt);
+ } else if(eventType.equals(CallPeerChangeEvent
+ .CALL_PEER_STATE_CHANGE))
+ {
+ listener.peerStateChanged(evt);
+ }
+ }
+ catch(Throwable t)
{
- listener.peerStateChanged(evt);
+ logger.error("Error dispatching event of type"
+ + eventType + " in " + listener, t);
}
}
}
diff --git a/src/net/java/sip/communicator/service/protocol/media/MediaAwareCallPeer.java b/src/net/java/sip/communicator/service/protocol/media/MediaAwareCallPeer.java
index efcf238..23f43be 100644
--- a/src/net/java/sip/communicator/service/protocol/media/MediaAwareCallPeer.java
+++ b/src/net/java/sip/communicator/service/protocol/media/MediaAwareCallPeer.java
@@ -515,12 +515,18 @@ public abstract class MediaAwareCallPeer
synchronized(mediaHandler)
{
- super.setState(newState, reason, reasonCode);
-
- if (CallPeerState.DISCONNECTED.equals(newState)
- || CallPeerState.FAILED.equals(newState))
+ try
+ {
+ super.setState(newState, reason, reasonCode);
+ }
+ finally
{
- mediaHandler.close();
+ // make sure whatever happens to close the media
+ if (CallPeerState.DISCONNECTED.equals(newState)
+ || CallPeerState.FAILED.equals(newState))
+ {
+ mediaHandler.close();
+ }
}
}
}