Repository: struts
Updated Branches:
refs/heads/develop eecd90763 -> 583234b8c
Adds additional logging of missing keys in resource bundles
Project: http://git-wip-us.apache.org/repos/asf/struts/repo
Commit: http://git-wip-us.apache.org/repos/asf/struts/commit/583234b8
Tree: http://git-wip-us.apache.org/repos/asf/struts/tree/583234b8
Diff: http://git-wip-us.apache.org/repos/asf/struts/diff/583234b8
Branch: refs/heads/develop
Commit: 583234b8ccc24dc52c1b718a153126f7319de262
Parents: eecd907
Author: Lukasz Lenart
Authored: Mon Aug 25 08:42:50 2014 +0200
Committer: Lukasz Lenart
Committed: Mon Aug 25 08:42:50 2014 +0200
--
.../apache/struts2/dispatcher/Dispatcher.java | 3 ++
.../xwork2/util/LocalizedTextUtil.java | 38 +++-
2 files changed, 32 insertions(+), 9 deletions(-)
--
http://git-wip-us.apache.org/repos/asf/struts/blob/583234b8/core/src/main/java/org/apache/struts2/dispatcher/Dispatcher.java
--
diff --git a/core/src/main/java/org/apache/struts2/dispatcher/Dispatcher.java
b/core/src/main/java/org/apache/struts2/dispatcher/Dispatcher.java
index 95dc308..436490e 100644
--- a/core/src/main/java/org/apache/struts2/dispatcher/Dispatcher.java
+++ b/core/src/main/java/org/apache/struts2/dispatcher/Dispatcher.java
@@ -439,6 +439,9 @@ public class Dispatcher {
boolean reloadi18n =
Boolean.valueOf(container.getInstance(String.class,
StrutsConstants.STRUTS_I18N_RELOAD));
LocalizedTextUtil.setReloadBundles(reloadi18n);
+boolean devMode = Boolean.valueOf(container.getInstance(String.class,
StrutsConstants.STRUTS_DEVMODE));
+LocalizedTextUtil.setDevMode(devMode);
+
return container;
}
http://git-wip-us.apache.org/repos/asf/struts/blob/583234b8/xwork-core/src/main/java/com/opensymphony/xwork2/util/LocalizedTextUtil.java
--
diff --git
a/xwork-core/src/main/java/com/opensymphony/xwork2/util/LocalizedTextUtil.java
b/xwork-core/src/main/java/com/opensymphony/xwork2/util/LocalizedTextUtil.java
index 9aad928..ec7860e 100644
---
a/xwork-core/src/main/java/com/opensymphony/xwork2/util/LocalizedTextUtil.java
+++
b/xwork-core/src/main/java/com/opensymphony/xwork2/util/LocalizedTextUtil.java
@@ -86,9 +86,13 @@ import java.util.concurrent.ConcurrentMap;
*/
public class LocalizedTextUtil {
-private static final ConcurrentMap> classLoaderMap =
new ConcurrentHashMap>();
private static final Logger LOG =
LoggerFactory.getLogger(LocalizedTextUtil.class);
+
+private static final ConcurrentMap> classLoaderMap =
new ConcurrentHashMap>();
+
private static boolean reloadBundles = false;
+private static boolean devMode;
+
private static final ConcurrentMap bundlesMap =
new ConcurrentHashMap();
private static final ConcurrentMap
messageFormats = new ConcurrentHashMap();
private static final ConcurrentMap
delegatedClassLoaderMap = new ConcurrentHashMap();
@@ -120,6 +124,10 @@ public class LocalizedTextUtil {
LocalizedTextUtil.reloadBundles = reloadBundles;
}
+public static void setDevMode(boolean devMode) {
+LocalizedTextUtil.devMode = devMode;
+}
+
/**
* Add's the bundle to the internal list of default bundles.
*
@@ -129,7 +137,7 @@ public class LocalizedTextUtil {
*/
public static void addDefaultResourceBundle(String resourceBundleName) {
//make sure this doesn't get added more than once
-ClassLoader ccl = null;
+ClassLoader ccl;
synchronized (XWORK_MESSAGES_BUNDLE) {
ccl = getCurrentThreadContextClassLoader();
List bundles = classLoaderMap.get(ccl.hashCode());
@@ -207,7 +215,11 @@ public class LocalizedTextUtil {
try {
return bundle.getString(aTextName);
} catch (MissingResourceException e) {
-// ignore and try others
+if (devMode) {
+LOG.warn("Missing key [#0] in bundle [#1]!",
aTextName, bundleName);
+} else if (LOG.isDebugEnabled()) {
+LOG.debug("Missing key [#0] in bundle [#1]!",
aTextName, bundleName);
+}
}
}
}
@@ -265,6 +277,9 @@ public class LocalizedTextUtil {
bundle = bundlesMap.get(key);
}
} catch (MissingResourceException e) {
+if (LOG.isDebugEnabled()) {
+LOG.debug("Missing resource bundle [#0]!",
aBundleName);
+}
}
}
}
@@ -273,8 +288,6 @@ public class LocalizedTextUtil {
/**
* Sets a {@link ClassLo