Author: dkulp Date: Thu Nov 1 15:47:27 2012 New Revision: 1404648 URL: http://svn.apache.org/viewvc?rev=1404648&view=rev Log: Merged revisions 1404631 via git cherry-pick from https://svn.apache.org/repos/asf/cxf/branches/2.6.x-fixes
........ r1404631 | dkulp | 2012-11-01 11:14:58 -0400 (Thu, 01 Nov 2012) | 10 lines Merged revisions 1404620 via git cherry-pick from https://svn.apache.org/repos/asf/cxf/trunk ........ r1404620 | dkulp | 2012-11-01 10:52:14 -0400 (Thu, 01 Nov 2012) | 2 lines Some cleanup around the bundle handling when grabbing loggers ........ ........ Modified: cxf/branches/2.5.x-fixes/common/common/src/main/java/org/apache/cxf/common/logging/LogUtils.java Modified: cxf/branches/2.5.x-fixes/common/common/src/main/java/org/apache/cxf/common/logging/LogUtils.java URL: http://svn.apache.org/viewvc/cxf/branches/2.5.x-fixes/common/common/src/main/java/org/apache/cxf/common/logging/LogUtils.java?rev=1404648&r1=1404647&r2=1404648&view=diff ============================================================================== --- cxf/branches/2.5.x-fixes/common/common/src/main/java/org/apache/cxf/common/logging/LogUtils.java (original) +++ cxf/branches/2.5.x-fixes/common/common/src/main/java/org/apache/cxf/common/logging/LogUtils.java Thu Nov 1 15:47:27 2012 @@ -234,6 +234,29 @@ public final class LogUtils { Thread.currentThread().setContextClassLoader(n); } try { + Logger logger = null; + ResourceBundle b = null; + if (name == null) { + //grab the bundle prior to the call to Logger.getLogger(...) so the + //ResourceBundle can be loaded outside the big sync block that getLogger really is + name = BundleUtils.getBundleName(cls); + try { + b = BundleUtils.getBundle(cls); + } catch (MissingResourceException rex) { + //ignore + } + } else { + name = BundleUtils.getBundleName(cls, name); + try { + b = BundleUtils.getBundle(cls, name); + } catch (MissingResourceException rex) { + //ignore + } + } + if (b != null) { + b.getLocale(); + } + if (loggerClass != null) { try { Constructor<?> cns = loggerClass.getConstructor(String.class, String.class); @@ -262,22 +285,18 @@ public final class LogUtils { throw new RuntimeException(e); } } - if (name == null) { - ResourceBundle b = null; - try { - //grab the bundle prior to the call to Logger.getLogger(...) so the - //ResourceBundle can be loaded outside the big sync block that getLogger really is - b = BundleUtils.getBundle(cls); - b.getLocale(); - return Logger.getLogger(loggerName, BundleUtils.getBundleName(cls)); //NOPMD - } catch (MissingResourceException rex) { - return Logger.getLogger(loggerName); //NOPMD - } finally { - b = null; - } - } else { - return Logger.getLogger(loggerName, BundleUtils.getBundleName(cls, name)); //NOPMD + + try { + logger = Logger.getLogger(loggerName, name); //NOPMD + } catch (IllegalArgumentException iae) { + //likely a mismatch on the bundle name, just return the default + logger = Logger.getLogger(loggerName); //NOPMD + } catch (MissingResourceException rex) { + logger = Logger.getLogger(loggerName); //NOPMD + } finally { + b = null; } + return logger; } finally { if (n != orig) { Thread.currentThread().setContextClassLoader(orig);
