diff options
8 files changed, 10 insertions, 10 deletions
diff --git a/src/java/org/apache/poi/poifs/crypt/CryptoFunctions.java b/src/java/org/apache/poi/poifs/crypt/CryptoFunctions.java index 6a16e3f9dc..4a984929b6 100644 --- a/src/java/org/apache/poi/poifs/crypt/CryptoFunctions.java +++ b/src/java/org/apache/poi/poifs/crypt/CryptoFunctions.java @@ -324,7 +324,7 @@ public class CryptoFunctions { } try { - ClassLoader cl = Thread.currentThread().getContextClassLoader(); + ClassLoader cl = CryptoFunctions.class.getClassLoader(); String bcProviderName = "org.bouncycastle.jce.provider.BouncyCastleProvider"; Class<Provider> clazz = (Class<Provider>)cl.loadClass(bcProviderName); Security.addProvider(clazz.newInstance()); diff --git a/src/java/org/apache/poi/poifs/crypt/EncryptionInfo.java b/src/java/org/apache/poi/poifs/crypt/EncryptionInfo.java index c70105fb93..df08b3cf5b 100644 --- a/src/java/org/apache/poi/poifs/crypt/EncryptionInfo.java +++ b/src/java/org/apache/poi/poifs/crypt/EncryptionInfo.java @@ -217,7 +217,7 @@ public class EncryptionInfo implements Cloneable { */ protected static EncryptionInfoBuilder getBuilder(EncryptionMode encryptionMode) throws ClassNotFoundException, IllegalAccessException, InstantiationException { - ClassLoader cl = Thread.currentThread().getContextClassLoader(); + ClassLoader cl = EncryptionInfo.class.getClassLoader(); EncryptionInfoBuilder eib; eib = (EncryptionInfoBuilder)cl.loadClass(encryptionMode.builder).newInstance(); return eib; diff --git a/src/java/org/apache/poi/sl/draw/DrawPictureShape.java b/src/java/org/apache/poi/sl/draw/DrawPictureShape.java index 2d3764e8a2..fcca6d07a7 100644 --- a/src/java/org/apache/poi/sl/draw/DrawPictureShape.java +++ b/src/java/org/apache/poi/sl/draw/DrawPictureShape.java @@ -72,7 +72,7 @@ public class DrawPictureShape extends DrawSimpleShape { try { @SuppressWarnings("unchecked") Class<? extends ImageRenderer> irc = (Class<? extends ImageRenderer>) - Thread.currentThread().getContextClassLoader().loadClass(WMF_IMAGE_RENDERER); + DrawPictureShape.class.getClassLoader().loadClass(WMF_IMAGE_RENDERER); return irc.newInstance(); } catch (Exception e) { // WMF image renderer is not on the classpath, continuing with BitmapRenderer diff --git a/src/java/org/apache/poi/sl/usermodel/SlideShowFactory.java b/src/java/org/apache/poi/sl/usermodel/SlideShowFactory.java index 31c669cf03..7f4ab04b29 100644 --- a/src/java/org/apache/poi/sl/usermodel/SlideShowFactory.java +++ b/src/java/org/apache/poi/sl/usermodel/SlideShowFactory.java @@ -292,7 +292,7 @@ public class SlideShowFactory { P extends TextParagraph<S,P,? extends TextRun> > SlideShow<S,P> createSlideShow(String factoryClass, Object args[]) throws IOException, EncryptedDocumentException { try { - Class<?> clazz = Thread.currentThread().getContextClassLoader().loadClass(factoryClass); + Class<?> clazz = SlideShowFactory.class.getClassLoader().loadClass(factoryClass); Class<?> argsClz[] = new Class<?>[args.length]; int i=0; for (Object o : args) { diff --git a/src/java/org/apache/poi/ss/usermodel/WorkbookFactory.java b/src/java/org/apache/poi/ss/usermodel/WorkbookFactory.java index d62fdfc85f..7ac7967340 100644 --- a/src/java/org/apache/poi/ss/usermodel/WorkbookFactory.java +++ b/src/java/org/apache/poi/ss/usermodel/WorkbookFactory.java @@ -294,7 +294,7 @@ public class WorkbookFactory { private static Workbook createWorkbook(String factoryClass, Object args[]) throws IOException, EncryptedDocumentException { try { - Class<?> clazz = Thread.currentThread().getContextClassLoader().loadClass(factoryClass); + Class<?> clazz = WorkbookFactory.class.getClassLoader().loadClass(factoryClass); Class<?> argsClz[] = new Class<?>[args.length]; int i=0; for (Object o : args) { diff --git a/src/ooxml/testcases/org/apache/poi/ooxml/TestPOIXMLDocument.java b/src/ooxml/testcases/org/apache/poi/ooxml/TestPOIXMLDocument.java index 056ecbb8e9..393e474468 100644 --- a/src/ooxml/testcases/org/apache/poi/ooxml/TestPOIXMLDocument.java +++ b/src/ooxml/testcases/org/apache/poi/ooxml/TestPOIXMLDocument.java @@ -356,8 +356,7 @@ public final class TestPOIXMLDocument { } }; - Thread thread = Thread.currentThread(); - ClassLoader cl = thread.getContextClassLoader(); + ClassLoader cl = getClass().getClassLoader(); UncaughtHandler uh = new UncaughtHandler(); // check schema type loading and check if we could run in an OOM diff --git a/src/resources/devtools/forbidden-signatures.txt b/src/resources/devtools/forbidden-signatures.txt index 2ea708740c..e64d7e02cf 100644 --- a/src/resources/devtools/forbidden-signatures.txt +++ b/src/resources/devtools/forbidden-signatures.txt @@ -79,8 +79,9 @@ java.net.InetAddress#getCanonicalHostName() java.net.InetSocketAddress#getHostName() @ Use getHostString() instead, which avoids a DNS lookup
-@defaultMessage this method needs special permission
-java.lang.Thread#getAllStackTraces()
+
+java.lang.Thread#getAllStackTraces() @ this method needs special permission
+java.lang.Thread#getContextClassLoader() @ use getClass().getClassLoader() instead of getContextClassLoader() (see https://stackoverflow.com/a/36228195/2066598)
@defaultMessage Avoid unchecked warnings by using Collections#empty(List|Map|Set) methods
java.util.Collections#EMPTY_LIST
diff --git a/src/scratchpad/src/org/apache/poi/hslf/model/HSLFMetroShape.java b/src/scratchpad/src/org/apache/poi/hslf/model/HSLFMetroShape.java index 205f3e6e52..0b28c76f07 100644 --- a/src/scratchpad/src/org/apache/poi/hslf/model/HSLFMetroShape.java +++ b/src/scratchpad/src/org/apache/poi/hslf/model/HSLFMetroShape.java @@ -75,7 +75,7 @@ public class HSLFMetroShape<T extends Shape<?,?>> { } // org.apache.poi.xslf.usermodel.XSLFMetroShape - ClassLoader cl = Thread.currentThread().getContextClassLoader(); + ClassLoader cl = getClass().getClassLoader(); try { Class<?> ms = cl.loadClass("org.apache.poi.xslf.usermodel.XSLFMetroShape"); Method m = ms.getMethod("parseShape", byte[].class); |