Author: dkulp
Date: Thu Nov 1 14:52:14 2012
New Revision: 1404620
URL: http://svn.apache.org/viewvc?rev=1404620&view=rev
Log:
Some cleanup around the bundle handling when grabbing loggers
Modified:
cxf/trunk/api/src/main/java/org/apache/cxf/common/logging/LogUtils.java
Modified:
cxf/trunk/api/src/main/java/org/apache/cxf/common/logging/LogUtils.java
URL:
http://svn.apache.org/viewvc/cxf/trunk/api/src/main/java/org/apache/cxf/common/logging/LogUtils.java?rev=1404620&r1=1404619&r2=1404620&view=diff
==============================================================================
--- cxf/trunk/api/src/main/java/org/apache/cxf/common/logging/LogUtils.java
(original)
+++ cxf/trunk/api/src/main/java/org/apache/cxf/common/logging/LogUtils.java Thu
Nov 1 14:52:14 2012
@@ -238,6 +238,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);
@@ -266,22 +289,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);