#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
This commit is contained in:
parent
54b8260ccc
commit
d3b5a0141e
@ -324,7 +324,7 @@ public class CryptoFunctions {
|
|||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
ClassLoader cl = Thread.currentThread().getContextClassLoader();
|
ClassLoader cl = CryptoFunctions.class.getClassLoader();
|
||||||
String bcProviderName = "org.bouncycastle.jce.provider.BouncyCastleProvider";
|
String bcProviderName = "org.bouncycastle.jce.provider.BouncyCastleProvider";
|
||||||
Class<Provider> clazz = (Class<Provider>)cl.loadClass(bcProviderName);
|
Class<Provider> clazz = (Class<Provider>)cl.loadClass(bcProviderName);
|
||||||
Security.addProvider(clazz.newInstance());
|
Security.addProvider(clazz.newInstance());
|
||||||
|
@ -217,7 +217,7 @@ public class EncryptionInfo implements Cloneable {
|
|||||||
*/
|
*/
|
||||||
protected static EncryptionInfoBuilder getBuilder(EncryptionMode encryptionMode)
|
protected static EncryptionInfoBuilder getBuilder(EncryptionMode encryptionMode)
|
||||||
throws ClassNotFoundException, IllegalAccessException, InstantiationException {
|
throws ClassNotFoundException, IllegalAccessException, InstantiationException {
|
||||||
ClassLoader cl = Thread.currentThread().getContextClassLoader();
|
ClassLoader cl = EncryptionInfo.class.getClassLoader();
|
||||||
EncryptionInfoBuilder eib;
|
EncryptionInfoBuilder eib;
|
||||||
eib = (EncryptionInfoBuilder)cl.loadClass(encryptionMode.builder).newInstance();
|
eib = (EncryptionInfoBuilder)cl.loadClass(encryptionMode.builder).newInstance();
|
||||||
return eib;
|
return eib;
|
||||||
|
@ -72,7 +72,7 @@ public class DrawPictureShape extends DrawSimpleShape {
|
|||||||
try {
|
try {
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
Class<? extends ImageRenderer> irc = (Class<? extends ImageRenderer>)
|
Class<? extends ImageRenderer> irc = (Class<? extends ImageRenderer>)
|
||||||
Thread.currentThread().getContextClassLoader().loadClass(WMF_IMAGE_RENDERER);
|
DrawPictureShape.class.getClassLoader().loadClass(WMF_IMAGE_RENDERER);
|
||||||
return irc.newInstance();
|
return irc.newInstance();
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
// WMF image renderer is not on the classpath, continuing with BitmapRenderer
|
// WMF image renderer is not on the classpath, continuing with BitmapRenderer
|
||||||
|
@ -292,7 +292,7 @@ public class SlideShowFactory {
|
|||||||
P extends TextParagraph<S,P,? extends TextRun>
|
P extends TextParagraph<S,P,? extends TextRun>
|
||||||
> SlideShow<S,P> createSlideShow(String factoryClass, Object args[]) throws IOException, EncryptedDocumentException {
|
> SlideShow<S,P> createSlideShow(String factoryClass, Object args[]) throws IOException, EncryptedDocumentException {
|
||||||
try {
|
try {
|
||||||
Class<?> clazz = Thread.currentThread().getContextClassLoader().loadClass(factoryClass);
|
Class<?> clazz = SlideShowFactory.class.getClassLoader().loadClass(factoryClass);
|
||||||
Class<?> argsClz[] = new Class<?>[args.length];
|
Class<?> argsClz[] = new Class<?>[args.length];
|
||||||
int i=0;
|
int i=0;
|
||||||
for (Object o : args) {
|
for (Object o : args) {
|
||||||
|
@ -294,7 +294,7 @@ public class WorkbookFactory {
|
|||||||
|
|
||||||
private static Workbook createWorkbook(String factoryClass, Object args[]) throws IOException, EncryptedDocumentException {
|
private static Workbook createWorkbook(String factoryClass, Object args[]) throws IOException, EncryptedDocumentException {
|
||||||
try {
|
try {
|
||||||
Class<?> clazz = Thread.currentThread().getContextClassLoader().loadClass(factoryClass);
|
Class<?> clazz = WorkbookFactory.class.getClassLoader().loadClass(factoryClass);
|
||||||
Class<?> argsClz[] = new Class<?>[args.length];
|
Class<?> argsClz[] = new Class<?>[args.length];
|
||||||
int i=0;
|
int i=0;
|
||||||
for (Object o : args) {
|
for (Object o : args) {
|
||||||
|
@ -356,8 +356,7 @@ public final class TestPOIXMLDocument {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
Thread thread = Thread.currentThread();
|
ClassLoader cl = getClass().getClassLoader();
|
||||||
ClassLoader cl = thread.getContextClassLoader();
|
|
||||||
UncaughtHandler uh = new UncaughtHandler();
|
UncaughtHandler uh = new UncaughtHandler();
|
||||||
|
|
||||||
// check schema type loading and check if we could run in an OOM
|
// check schema type loading and check if we could run in an OOM
|
||||||
|
@ -79,8 +79,9 @@ java.net.InetAddress#getCanonicalHostName()
|
|||||||
|
|
||||||
java.net.InetSocketAddress#getHostName() @ Use getHostString() instead, which avoids a DNS lookup
|
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
|
@defaultMessage Avoid unchecked warnings by using Collections#empty(List|Map|Set) methods
|
||||||
java.util.Collections#EMPTY_LIST
|
java.util.Collections#EMPTY_LIST
|
||||||
|
@ -75,7 +75,7 @@ public class HSLFMetroShape<T extends Shape<?,?>> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// org.apache.poi.xslf.usermodel.XSLFMetroShape
|
// org.apache.poi.xslf.usermodel.XSLFMetroShape
|
||||||
ClassLoader cl = Thread.currentThread().getContextClassLoader();
|
ClassLoader cl = getClass().getClassLoader();
|
||||||
try {
|
try {
|
||||||
Class<?> ms = cl.loadClass("org.apache.poi.xslf.usermodel.XSLFMetroShape");
|
Class<?> ms = cl.loadClass("org.apache.poi.xslf.usermodel.XSLFMetroShape");
|
||||||
Method m = ms.getMethod("parseShape", byte[].class);
|
Method m = ms.getMethod("parseShape", byte[].class);
|
||||||
|
Loading…
Reference in New Issue
Block a user