Fixes a NullPointerException thrown when the Update button of the plug-in manager is invoked for the IRC protocol provider plug-in.

cusax-fix
Lyubomir Marinov 17 years ago
parent 7216c6b4f8
commit 6c2937b504

@ -23,10 +23,11 @@
* @author Emil Ivov
*/
public class ArgDelegationPeerImpl
implements ArgDelegationPeer, ServiceListener
implements ArgDelegationPeer,
ServiceListener
{
private static final Logger logger =
Logger.getLogger(ArgDelegationPeerImpl.class);
private static final Logger logger
= Logger.getLogger(ArgDelegationPeerImpl.class);
/**
* The list of uriHandlers that we are currently aware of.
@ -43,31 +44,30 @@ public class ArgDelegationPeerImpl
*/
public ArgDelegationPeerImpl(BundleContext bundleContext)
{
ServiceReference[] uriHandlerRefs = null;
ServiceReference[] uriHandlerRefs;
synchronized (uriHandlers)
try
{
try
{
uriHandlerRefs = bundleContext.getServiceReferences(
uriHandlerRefs = bundleContext.getServiceReferences(
UriHandler.class.getName(), null);
}
catch (InvalidSyntaxException exc)
{
// this shouldn't happen because we aren't using a filter
// but let's log just the same.
logger.info("An error occurred while retrieving UriHandlers",
exc);
return;
}
}
catch (InvalidSyntaxException exc)
{
// this shouldn't happen because we aren't using a filter
// but let's log just the same.
logger.info("An error occurred while retrieving UriHandlers", exc);
return;
}
if(uriHandlerRefs == null)
{
//none URI handlers are registered at this point. Some might
//come later.
return;
}
if(uriHandlerRefs == null)
{
//none URI handlers are registered at this point. Some might
//come later.
return;
}
synchronized (uriHandlers)
{
for (ServiceReference uriHandlerRef : uriHandlerRefs)
{
UriHandler uriHandler = (UriHandler) bundleContext
@ -86,34 +86,41 @@ public ArgDelegationPeerImpl(BundleContext bundleContext)
*/
public void serviceChanged(ServiceEvent event)
{
synchronized (uriHandlers)
{
BundleContext bc = event.getServiceReference().getBundle()
.getBundleContext();
BundleContext bc
= event.getServiceReference().getBundle().getBundleContext();
/*
* TODO When the Update button of the plug-in manager is invoked for the
* IRC protocol provider plug-in, bc is of value null and thus causes a
* NullPointerException. Determine whether it is a problem (in general)
* to not process ServiceEvent.UNREGISTERING in such a case.
*/
if (bc == null)
return;
Object service = bc.getService(event.getServiceReference());
Object service = bc.getService(event.getServiceReference());
//we are only interested in UriHandler-s
if(!(service instanceof UriHandler) )
{
return;
}
//we are only interested in UriHandler-s
if (!(service instanceof UriHandler))
return;
if (event.getType() == ServiceEvent.MODIFIED
|| event.getType() == ServiceEvent.REGISTERED)
{
UriHandler uriHandler = (UriHandler) bc.getService(event
.getServiceReference());
UriHandler uriHandler = (UriHandler) service;
uriHandlers.put(uriHandler.getProtocol(), uriHandler);
}
else if (event.getType() == ServiceEvent.UNREGISTERING)
synchronized (uriHandlers)
{
switch (event.getType())
{
UriHandler uriHandler = (UriHandler) bc.getService(event
.getServiceReference());
case ServiceEvent.MODIFIED:
case ServiceEvent.REGISTERED:
uriHandlers.put(uriHandler.getProtocol(), uriHandler);
break;
case ServiceEvent.UNREGISTERING:
String protocol = uriHandler.getProtocol();
if(uriHandlers.get(uriHandler.getProtocol()) == uriHandler)
uriHandlers.remove(uriHandler.getProtocol());
if(uriHandlers.get(protocol) == uriHandler)
uriHandlers.remove(protocol);
break;
}
}
}
@ -148,7 +155,10 @@ public void handleUri(String uriArg)
String scheme = uriArg.substring(0, colonIndex);
UriHandler handler = uriHandlers.get(scheme);
UriHandler handler;
synchronized (uriHandlers) {
handler = uriHandlers.get(scheme);
}
//if handler is null we need to tell the user.
if(handler == null)
@ -171,6 +181,10 @@ public void handleUri(String uriArg)
//catch every possible exception
catch(Throwable thr)
{
// ThreadDeath should always be re-thrown.
if (thr instanceof ThreadDeath)
throw (ThreadDeath) thr;
ArgDelegationActivator.getUIService().getPopupDialog()
.showMessagePopupDialog(
"Error handling " + uriArg,
@ -191,6 +205,4 @@ public void handleConcurrentInvocationRequest()
{
ArgDelegationActivator.getUIService().setVisible(true);
}
}

@ -8,11 +8,11 @@
import java.util.*;
import net.java.sip.communicator.service.configuration.ConfigurationService;
import net.java.sip.communicator.service.configuration.*;
import net.java.sip.communicator.service.gui.*;
import net.java.sip.communicator.service.protocol.ProtocolProviderService;
import net.java.sip.communicator.service.protocol.*;
import net.java.sip.communicator.service.resources.*;
import net.java.sip.communicator.util.Logger;
import net.java.sip.communicator.util.*;
import org.osgi.framework.*;
@ -21,11 +21,10 @@
*
* @author Thomas Hofer
*/
public class AutoAwayActivator implements BundleActivator
public class AutoAwayActivator
implements BundleActivator
{
private static Logger logger = Logger
.getLogger(AutoAwayActivator.class);
private static Logger logger = Logger.getLogger(AutoAwayActivator.class);
static BundleContext bundleContext = null;

@ -9,7 +9,7 @@
import java.awt.*;
import java.util.*;
import net.java.sip.communicator.service.configuration.ConfigurationService;
import net.java.sip.communicator.service.configuration.*;
import net.java.sip.communicator.service.protocol.*;
/**
@ -17,9 +17,9 @@
* not moved, all accounts are set to "Away" or similar states.
*
* @author Thomas Hofer
*
*/
public class StatusUpdateThread implements Runnable
public class StatusUpdateThread
implements Runnable
{
private boolean run = false;
private Point lastPosition = null;

Loading…
Cancel
Save