Browse Source

#62564 - replace Thread.currentThread().getContextClassLoader() with getClass().getClassLoader()

git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1836590 13f79535-47bb-0310-9956-ffa450edef68
pull/117/head
Andreas Beeker 5 years ago
parent
commit
d3b5a0141e

+ 1
- 1
src/java/org/apache/poi/poifs/crypt/CryptoFunctions.java View File

@@ -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());

+ 1
- 1
src/java/org/apache/poi/poifs/crypt/EncryptionInfo.java View File

@@ -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;

+ 1
- 1
src/java/org/apache/poi/sl/draw/DrawPictureShape.java View File

@@ -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

+ 1
- 1
src/java/org/apache/poi/sl/usermodel/SlideShowFactory.java View File

@@ -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) {

+ 1
- 1
src/java/org/apache/poi/ss/usermodel/WorkbookFactory.java View File

@@ -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) {

+ 1
- 2
src/ooxml/testcases/org/apache/poi/ooxml/TestPOIXMLDocument.java View File

@@ -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

+ 3
- 2
src/resources/devtools/forbidden-signatures.txt View File

@@ -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

+ 1
- 1
src/scratchpad/src/org/apache/poi/hslf/model/HSLFMetroShape.java View File

@@ -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);

Loading…
Cancel
Save