Skip to content
Permalink
Browse files
BVAL-165 tccl should always be preferred over class.getClassLoader si…
…nce it is always possible to set it right and it enables tree classloading graphs to work (whereas the opposite breaks it by design)
  • Loading branch information
rmannibucau committed Oct 30, 2018
1 parent e3023a4 commit 7f5df08d63e1e5ca9bcd2cbc16486f48cac5d449
Showing 4 changed files with 4 additions and 4 deletions.
@@ -229,7 +229,7 @@ private void set(AttributesImpl attrs, String uri, String localName, String qNam
}

static Schema loadSchema(String resource) {
final URL schemaUrl = Reflection.loaderFromClassOrThread(XmlUtils.class).getResource(resource);
final URL schemaUrl = Reflection.loaderFromThreadOrClass(XmlUtils.class).getResource(resource);
try {
return SCHEMA_FACTORY.newSchema(schemaUrl);
} catch (SAXException e) {
@@ -160,7 +160,7 @@ private boolean isQualifiedClass(String clazz) {

private Class<?> loadClass(final String className) {
try {
return Reflection.toClass(className, Reflection.loaderFromClassOrThread(ValidationMappingParser.class));
return Reflection.toClass(className, Reflection.loaderFromThreadOrClass(ValidationMappingParser.class));
} catch (ClassNotFoundException ex) {
throw Exceptions.create(ValidationException::new, ex, "Unable to load class: %s", className);
}
@@ -43,7 +43,7 @@ class XmlUtils {
private static final SchemaFactory SCHEMA_FACTORY = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI);

static Schema loadSchema(String resource) {
final URL schemaUrl = Reflection.loaderFromClassOrThread(XmlUtils.class).getResource(resource);
final URL schemaUrl = Reflection.loaderFromThreadOrClass(XmlUtils.class).getResource(resource);
try {
return SCHEMA_FACTORY.newSchema(schemaUrl);
} catch (SAXException e) {
@@ -245,7 +245,7 @@ public static ClassLoader loaderFromThreadOrClass(final Class<?> fallbackClass)
}

public static Class<?> toClass(String className) throws ClassNotFoundException {
return toClass(className, loaderFromClassOrThread(Reflection.class));
return toClass(className, loaderFromThreadOrClass(Reflection.class));
}

/**

0 comments on commit 7f5df08

Please sign in to comment.