aboutsummaryrefslogtreecommitdiffstats
path: root/src/ooxml/java/org/apache/poi/util
diff options
context:
space:
mode:
authorAndreas Beeker <kiwiwings@apache.org>2015-07-25 00:25:07 +0000
committerAndreas Beeker <kiwiwings@apache.org>2015-07-25 00:25:07 +0000
commit7b7274bdcb00a646d9e0ea4feb73bf02e9129115 (patch)
tree691f68b2c7e2f4db0d03ab0a5a995e55c9cebeed /src/ooxml/java/org/apache/poi/util
parent7481844c98f174b1a0cedc56385872b8f4e343a2 (diff)
downloadpoi-7b7274bdcb00a646d9e0ea4feb73bf02e9129115.tar.gz
poi-7b7274bdcb00a646d9e0ea4feb73bf02e9129115.zip
fixed NPE with Jaxb proxy classes
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1692598 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/ooxml/java/org/apache/poi/util')
-rw-r--r--src/ooxml/java/org/apache/poi/util/OOXMLLite.java24
1 files changed, 15 insertions, 9 deletions
diff --git a/src/ooxml/java/org/apache/poi/util/OOXMLLite.java b/src/ooxml/java/org/apache/poi/util/OOXMLLite.java
index 0503dfa766..99719ba602 100644
--- a/src/ooxml/java/org/apache/poi/util/OOXMLLite.java
+++ b/src/ooxml/java/org/apache/poi/util/OOXMLLite.java
@@ -24,6 +24,9 @@ import java.io.InputStream;
import java.io.OutputStream;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
+import java.net.URL;
+import java.security.CodeSource;
+import java.security.ProtectionDomain;
import java.util.ArrayList;
import java.util.Enumeration;
import java.util.HashMap;
@@ -33,8 +36,9 @@ import java.util.Vector;
import java.util.jar.JarEntry;
import java.util.jar.JarFile;
import java.util.regex.Pattern;
-
+
import junit.framework.TestCase;
+
import org.junit.Test;
import org.junit.internal.TextListener;
import org.junit.runner.JUnitCore;import org.junit.runner.Result;
@@ -210,14 +214,16 @@ public final class OOXMLLite {
Vector<Class<?>> classes = (Vector<Class<?>>) _classes.get(appLoader);
Map<String, Class<?>> map = new HashMap<String, Class<?>>();
for (Class<?> cls : classes) {
- // e.g. proxy-classes, ...
- if(cls.getProtectionDomain() == null ||
- cls.getProtectionDomain().getCodeSource() == null) {
- continue;
- }
-
- String jar = cls.getProtectionDomain().getCodeSource().getLocation().toString();
- if(jar.indexOf(ptrn) != -1) map.put(cls.getName(), cls);
+ // e.g. proxy-classes, ...
+ ProtectionDomain pd = cls.getProtectionDomain();
+ if (pd == null) continue;
+ CodeSource cs = pd.getCodeSource();
+ if (cs == null) continue;
+ URL loc = cs.getLocation();
+ if (loc == null) continue;
+
+ String jar = loc.toString();
+ if(jar.indexOf(ptrn) != -1) map.put(cls.getName(), cls);
}
return map;
} catch (IllegalAccessException e) {