[CXF-6966] If classloader is null, don't use it for loading the bundles
Project: http://git-wip-us.apache.org/repos/asf/cxf/repo Commit: http://git-wip-us.apache.org/repos/asf/cxf/commit/c82c0e90 Tree: http://git-wip-us.apache.org/repos/asf/cxf/tree/c82c0e90 Diff: http://git-wip-us.apache.org/repos/asf/cxf/diff/c82c0e90 Branch: refs/heads/3.0.x-fixes Commit: c82c0e90dde47fb8c6329b1ee8eac3dae043ed75 Parents: 0d7ec24 Author: Daniel Kulp <dk...@apache.org> Authored: Fri Jul 22 11:31:05 2016 -0400 Committer: Daniel Kulp <dk...@apache.org> Committed: Mon Jul 25 10:29:52 2016 -0400 ---------------------------------------------------------------------- .../org/apache/cxf/common/i18n/BundleUtils.java | 24 ++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cxf/blob/c82c0e90/core/src/main/java/org/apache/cxf/common/i18n/BundleUtils.java ---------------------------------------------------------------------- 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 final class BundleUtils { 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 final class BundleUtils { */ 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); } }