1
0
Fork 0
mirror of https://github.com/vanitasvitae/Smack.git synced 2024-11-26 14:02:06 +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:
Gaston Dombiak 2006-08-02 22:31:23 +00:00 committed by gato
parent 47cc26e234
commit 8879234bbc
2 changed files with 19 additions and 3 deletions

View file

@ -25,7 +25,9 @@ import org.xmlpull.v1.XmlPullParser;
import java.io.InputStream;
import java.net.URL;
import java.util.ArrayList;
import java.util.Enumeration;
import java.util.List;
/**
* Represents the configuration of Smack. The configuration is used for:
@ -204,6 +206,13 @@ public final class SmackConfiguration {
ClassLoader[] classLoaders = new ClassLoader[2];
classLoaders[0] = SmackConfiguration.class.getClassLoader();
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();
}
}

View file

@ -384,7 +384,14 @@ public class ProviderManager {
ClassLoader[] classLoaders = new ClassLoader[2];
classLoaders[0] = ProviderManager.class.getClassLoader();
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() {