[CXF-6966] If classloader is null, don't use it for loading the bundles
diff --git a/core/src/main/java/org/apache/cxf/common/i18n/BundleUtils.java b/core/src/main/java/org/apache/cxf/common/i18n/BundleUtils.java
index 9aedfcf..5fdd3b4 100644
--- a/core/src/main/java/org/apache/cxf/common/i18n/BundleUtils.java
+++ b/core/src/main/java/org/apache/cxf/common/i18n/BundleUtils.java
@@ -77,13 +77,21 @@
public static ResourceBundle getBundle(Class<?> cls) {
try {
+ ClassLoader loader = cls.getClassLoader();
+ if (loader == null) {
+ return ResourceBundle.getBundle(getBundleName(cls), Locale.getDefault());
+ }
return ResourceBundle.getBundle(getBundleName(cls),
Locale.getDefault(),
- cls.getClassLoader());
+ loader);
} catch (MissingResourceException ex) {
+ ClassLoader loader = Thread.currentThread().getContextClassLoader();
+ if (loader == null) {
+ return ResourceBundle.getBundle(getBundleName(cls), Locale.getDefault());
+ }
return ResourceBundle.getBundle(getBundleName(cls),
Locale.getDefault(),
- Thread.currentThread().getContextClassLoader());
+ loader);
}
}
@@ -98,13 +106,21 @@
*/
public static ResourceBundle getBundle(Class<?> cls, String name) {
try {
+ ClassLoader loader = cls.getClassLoader();
+ if (loader == null) {
+ return ResourceBundle.getBundle(getBundleName(cls, name), Locale.getDefault());
+ }
return ResourceBundle.getBundle(getBundleName(cls, name),
Locale.getDefault(),
- cls.getClassLoader());
+ loader);
} catch (MissingResourceException ex) {
+ ClassLoader loader = Thread.currentThread().getContextClassLoader();
+ if (loader == null) {
+ return ResourceBundle.getBundle(getBundleName(cls, name), Locale.getDefault());
+ }
return ResourceBundle.getBundle(getBundleName(cls, name),
Locale.getDefault(),
- Thread.currentThread().getContextClassLoader());
+ loader);
}
}