mirror of
https://github.com/vanitasvitae/Smack.git
synced 2024-11-23 04:22:05 +01:00
Fixed potential error when #getClassLoader returns null. SMACK-162
git-svn-id: http://svn.igniterealtime.org/svn/repos/smack/trunk@4774 b35dd754-fafc-0310-a699-88a17e54d16e
This commit is contained in:
parent
47cc26e234
commit
8879234bbc
2 changed files with 19 additions and 3 deletions
|
@ -25,7 +25,9 @@ import org.xmlpull.v1.XmlPullParser;
|
||||||
|
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.Enumeration;
|
import java.util.Enumeration;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Represents the configuration of Smack. The configuration is used for:
|
* Represents the configuration of Smack. The configuration is used for:
|
||||||
|
@ -204,6 +206,13 @@ public final class SmackConfiguration {
|
||||||
ClassLoader[] classLoaders = new ClassLoader[2];
|
ClassLoader[] classLoaders = new ClassLoader[2];
|
||||||
classLoaders[0] = SmackConfiguration.class.getClassLoader();
|
classLoaders[0] = SmackConfiguration.class.getClassLoader();
|
||||||
classLoaders[1] = Thread.currentThread().getContextClassLoader();
|
classLoaders[1] = Thread.currentThread().getContextClassLoader();
|
||||||
return classLoaders;
|
// Clean up possible null values. Note that #getClassLoader may return a null value.
|
||||||
|
List<ClassLoader> loaders = new ArrayList<ClassLoader>();
|
||||||
|
for (ClassLoader classLoader : classLoaders) {
|
||||||
|
if (classLoader != null) {
|
||||||
|
loaders.add(classLoader);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return (ClassLoader[]) loaders.toArray();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -384,7 +384,14 @@ public class ProviderManager {
|
||||||
ClassLoader[] classLoaders = new ClassLoader[2];
|
ClassLoader[] classLoaders = new ClassLoader[2];
|
||||||
classLoaders[0] = ProviderManager.class.getClassLoader();
|
classLoaders[0] = ProviderManager.class.getClassLoader();
|
||||||
classLoaders[1] = Thread.currentThread().getContextClassLoader();
|
classLoaders[1] = Thread.currentThread().getContextClassLoader();
|
||||||
return classLoaders;
|
// Clean up possible null values. Note that #getClassLoader may return a null value.
|
||||||
|
List<ClassLoader> loaders = new ArrayList<ClassLoader>();
|
||||||
|
for (ClassLoader classLoader : classLoaders) {
|
||||||
|
if (classLoader != null) {
|
||||||
|
loaders.add(classLoader);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return (ClassLoader[]) loaders.toArray();
|
||||||
}
|
}
|
||||||
|
|
||||||
private ProviderManager() {
|
private ProviderManager() {
|
||||||
|
|
Loading…
Reference in a new issue