diff options
author | Lyubomir Marinov <lyubomir.marinov@jitsi.org> | 2013-11-13 22:33:32 +0200 |
---|---|---|
committer | Lyubomir Marinov <lyubomir.marinov@jitsi.org> | 2013-11-14 01:08:40 +0200 |
commit | c307d5ebab5e5f20c5550d6bf341731b8b47497a (patch) | |
tree | 3e41a279505d74a1edd058ea1af4f1d956c522a5 /src/net/java/sip/communicator/impl/netaddr | |
parent | 7dc1c4ac55b415aa671bfdfa3913350587bd62a3 (diff) | |
download | jitsi-c307d5ebab5e5f20c5550d6bf341731b8b47497a.zip jitsi-c307d5ebab5e5f20c5550d6bf341731b8b47497a.tar.gz jitsi-c307d5ebab5e5f20c5550d6bf341731b8b47497a.tar.bz2 |
Fixes NullPointerExceptions when PacketLoggingService is unavailable. Reproduced in Jitsi Videobridge.
Diffstat (limited to 'src/net/java/sip/communicator/impl/netaddr')
3 files changed, 36 insertions, 34 deletions
diff --git a/src/net/java/sip/communicator/impl/netaddr/Ice4jPacketLogger.java b/src/net/java/sip/communicator/impl/netaddr/Ice4jPacketLogger.java index 5263644..180f6b5 100644 --- a/src/net/java/sip/communicator/impl/netaddr/Ice4jPacketLogger.java +++ b/src/net/java/sip/communicator/impl/netaddr/Ice4jPacketLogger.java @@ -5,6 +5,7 @@ import org.jitsi.service.packetlogging.*; /** * Logs Packets coming and going through ice4j stack. + * * @author Damian Minkov */ public class Ice4jPacketLogger @@ -20,37 +21,42 @@ public class Ice4jPacketLogger * @param packetContent the content of the packet. * @param sender whether we are sending or not the packet. */ - public void logPacket(byte[] sourceAddress, + public void logPacket( + byte[] sourceAddress, int sourcePort, byte[] destinationAddress, int destinationPort, byte[] packetContent, boolean sender) { - if(isEnabled()) + if (isEnabled()) { - NetaddrActivator.getPacketLogging() - .logPacket( - PacketLoggingService.ProtocolName.ICE4J, - sourceAddress, - sourcePort, - destinationAddress, - destinationPort, - PacketLoggingService.TransportName.UDP, - sender, - packetContent - ); + NetaddrActivator.getPacketLogging().logPacket( + PacketLoggingService.ProtocolName.ICE4J, + sourceAddress, + sourcePort, + destinationAddress, + destinationPort, + PacketLoggingService.TransportName.UDP, + sender, + packetContent); } } /** * Checks whether the logger is enabled. - * @return <tt>true</tt> if the logger is enabled, <tt>false</tt> - * otherwise. + * + * @return <tt>true</tt> if the logger is enabled; <tt>false</tt>, + * otherwise */ public boolean isEnabled() { - return NetaddrActivator.getPacketLogging() - .isLoggingEnabled(PacketLoggingService.ProtocolName.ICE4J); + PacketLoggingService packetLoggingService + = NetaddrActivator.getPacketLogging(); + + return + (packetLoggingService != null) + && packetLoggingService.isLoggingEnabled( + PacketLoggingService.ProtocolName.ICE4J); } } diff --git a/src/net/java/sip/communicator/impl/netaddr/NetaddrActivator.java b/src/net/java/sip/communicator/impl/netaddr/NetaddrActivator.java index e0b10df..f682d98 100644 --- a/src/net/java/sip/communicator/impl/netaddr/NetaddrActivator.java +++ b/src/net/java/sip/communicator/impl/netaddr/NetaddrActivator.java @@ -103,11 +103,10 @@ public class NetaddrActivator { if (configurationService == null) { - ServiceReference confReference - = bundleContext.getServiceReference( - ConfigurationService.class.getName()); configurationService - = (ConfigurationService) bundleContext.getService(confReference); + = ServiceUtils.getService( + bundleContext, + ConfigurationService.class); } return configurationService; } @@ -125,12 +124,10 @@ public class NetaddrActivator { if (packetLoggingService == null) { - ServiceReference plReference - = bundleContext.getServiceReference( - PacketLoggingService.class.getName()); - packetLoggingService - = (PacketLoggingService)bundleContext.getService(plReference); + = ServiceUtils.getService( + bundleContext, + PacketLoggingService.class); } return packetLoggingService; } diff --git a/src/net/java/sip/communicator/impl/netaddr/NetworkAddressManagerServiceImpl.java b/src/net/java/sip/communicator/impl/netaddr/NetworkAddressManagerServiceImpl.java index 09eb5c2..1c57ae7 100644 --- a/src/net/java/sip/communicator/impl/netaddr/NetworkAddressManagerServiceImpl.java +++ b/src/net/java/sip/communicator/impl/netaddr/NetworkAddressManagerServiceImpl.java @@ -582,9 +582,7 @@ public class NetworkAddressManagerServiceImpl */ public Agent createIceAgent() { - Agent a = new Agent(); -// a.getStunStack(). - return a; + return new Agent(); } /** @@ -698,11 +696,12 @@ public class NetworkAddressManagerServiceImpl //rtp agent.createComponent( - stream, Transport.UDP, rtpPort, rtpPort, rtpPort + 100); - - //rtcpComp - agent.createComponent(stream, Transport.UDP, - rtpPort + 1, rtpPort + 1, rtpPort + 101); + stream, Transport.UDP, + rtpPort, rtpPort, rtpPort + 100); + //rtcp + agent.createComponent( + stream, Transport.UDP, + rtpPort + 1, rtpPort + 1, rtpPort + 101); return stream; } |