aboutsummaryrefslogtreecommitdiffstats
path: root/src/net/java/sip/communicator/plugin
diff options
context:
space:
mode:
authorIngo Bauersachs <ingo@jitsi.org>2014-11-08 11:45:01 +0100
committerIngo Bauersachs <ingo@jitsi.org>2014-11-08 12:20:19 +0100
commit5a19f774fcc126b76b4edc00f0a3d42e9df805dc (patch)
treef5a25bffca779805bb22293024f5bc2faffa2f86 /src/net/java/sip/communicator/plugin
parente561a0cc31fa3f314b34f221ad81f4596e61d0fd (diff)
downloadjitsi-5a19f774fcc126b76b4edc00f0a3d42e9df805dc.zip
jitsi-5a19f774fcc126b76b4edc00f0a3d42e9df805dc.tar.gz
jitsi-5a19f774fcc126b76b4edc00f0a3d42e9df805dc.tar.bz2
Always initialize the providers field to avoid NPE on exit
Diffstat (limited to 'src/net/java/sip/communicator/plugin')
-rw-r--r--src/net/java/sip/communicator/plugin/addrbook/AddrBookActivator.java51
1 files changed, 24 insertions, 27 deletions
diff --git a/src/net/java/sip/communicator/plugin/addrbook/AddrBookActivator.java b/src/net/java/sip/communicator/plugin/addrbook/AddrBookActivator.java
index 76e13d7..886ca87 100644
--- a/src/net/java/sip/communicator/plugin/addrbook/AddrBookActivator.java
+++ b/src/net/java/sip/communicator/plugin/addrbook/AddrBookActivator.java
@@ -105,7 +105,8 @@ public class AddrBookActivator
/**
* List of the providers with registration listener.
*/
- private static List<ProtocolProviderService> providers;
+ private static List<ProtocolProviderService> providers
+ = new ArrayList<ProtocolProviderService>();
/**
* The registered PhoneNumberI18nService.
@@ -503,42 +504,38 @@ public class AddrBookActivator
public static List<ProtocolProviderService> getProtocolProviders()
{
List<ProtocolProviderService> result;
-
- if(providers == null)
+ synchronized(providers)
{
- providers = new ArrayList<ProtocolProviderService>();
- synchronized(providers)
+ ServiceReference[] ppsRefs;
+ try
{
- ServiceReference[] ppsRefs;
- try
- {
- ppsRefs
- = bundleContext.getServiceReferences(
- ProtocolProviderService.class.getName(),
- null);
- }
- catch (InvalidSyntaxException ise)
- {
- ppsRefs = null;
- }
- if ((ppsRefs != null) && (ppsRefs.length != 0))
+ ppsRefs
+ = bundleContext.getServiceReferences(
+ ProtocolProviderService.class.getName(),
+ null);
+ }
+ catch (InvalidSyntaxException ise)
+ {
+ ppsRefs = null;
+ }
+
+ if ((ppsRefs != null) && (ppsRefs.length != 0))
+ {
+ for (ServiceReference ppsRef : ppsRefs)
{
- for (ServiceReference ppsRef : ppsRefs)
- {
- ProtocolProviderService pps
- = (ProtocolProviderService)
- bundleContext.getService(ppsRef);
- providers.add(pps);
- }
+ ProtocolProviderService pps
+ = (ProtocolProviderService)
+ bundleContext.getService(ppsRef);
+ providers.add(pps);
}
}
}
-
+
synchronized(providers)
{
result = new ArrayList<ProtocolProviderService>(providers);
}
-
+
return result;
}