Fixes NullPointerExceptions when PacketLoggingService is unavailable. Reproduced in Jitsi Videobridge.

cusax-fix
Lyubomir Marinov 12 years ago
parent 7dc1c4ac55
commit c307d5ebab

@ -5,6 +5,7 @@
/**
* 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);
}
}

@ -103,11 +103,10 @@ public static ConfigurationService getConfigurationService()
{
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 static PacketLoggingService getPacketLogging()
{
if (packetLoggingService == null)
{
ServiceReference plReference
= bundleContext.getServiceReference(
PacketLoggingService.class.getName());
packetLoggingService
= (PacketLoggingService)bundleContext.getService(plReference);
= ServiceUtils.getService(
bundleContext,
PacketLoggingService.class);
}
return packetLoggingService;
}

@ -582,9 +582,7 @@ public synchronized void removeNetworkConfigurationChangeListener(
*/
public Agent createIceAgent()
{
Agent a = new Agent();
// a.getStunStack().
return a;
return new Agent();
}
/**
@ -698,11 +696,12 @@ public IceMediaStream createIceStream( int rtpPort,
//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;
}

Loading…
Cancel
Save