mirror of
https://github.com/alibaba/druid.git
synced 2023-03-04 19:17:16 +00:00
bug fixed for null contextClassLoader
This commit is contained in:
@@ -53,20 +53,23 @@ public final class JdbcUtils implements JdbcConstants {
|
||||
|
||||
static {
|
||||
try {
|
||||
for (Enumeration<URL> e = Thread.currentThread().getContextClassLoader().getResources("META-INF/druid-driver.properties"); e.hasMoreElements();) {
|
||||
URL url = e.nextElement();
|
||||
ClassLoader ctxClassLoader = Thread.currentThread().getContextClassLoader();
|
||||
if (ctxClassLoader != null) {
|
||||
for (Enumeration<URL> e = ctxClassLoader.getResources("META-INF/druid-driver.properties"); e.hasMoreElements();) {
|
||||
URL url = e.nextElement();
|
||||
|
||||
Properties property = new Properties();
|
||||
Properties property = new Properties();
|
||||
|
||||
InputStream is = null;
|
||||
try {
|
||||
is = url.openStream();
|
||||
property.load(is);
|
||||
} finally {
|
||||
JdbcUtils.close(is);
|
||||
InputStream is = null;
|
||||
try {
|
||||
is = url.openStream();
|
||||
property.load(is);
|
||||
} finally {
|
||||
JdbcUtils.close(is);
|
||||
}
|
||||
|
||||
driverUrlMapping.putAll(property);
|
||||
}
|
||||
|
||||
driverUrlMapping.putAll(property);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
LOG.error("load druid-driver.properties error", e);
|
||||
@@ -486,7 +489,7 @@ public final class JdbcUtils implements JdbcConstants {
|
||||
// skip
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (clazz == null) {
|
||||
try {
|
||||
ClassLoader contextLoader = Thread.currentThread().getContextClassLoader();
|
||||
@@ -637,10 +640,13 @@ public final class JdbcUtils implements JdbcConstants {
|
||||
return null;
|
||||
}
|
||||
|
||||
try {
|
||||
clazz = Thread.currentThread().getContextClassLoader().loadClass(className);
|
||||
} catch (ClassNotFoundException e) {
|
||||
|
||||
ClassLoader ctxClassLoader = Thread.currentThread().getContextClassLoader();
|
||||
if (ctxClassLoader != null) {
|
||||
try {
|
||||
clazz = ctxClassLoader.loadClass(className);
|
||||
} catch (ClassNotFoundException e) {
|
||||
// skip
|
||||
}
|
||||
}
|
||||
|
||||
if (clazz != null) {
|
||||
|
||||
Reference in New Issue
Block a user