You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@struts.apache.org by lu...@apache.org on 2014/08/21 09:45:21 UTC
[01/12] git commit: This update enables struts to be used as JBoss AS
7/WildFly 8/JBoss EAP 6 module.
Repository: struts
Updated Branches:
refs/heads/develop d749bb8f7 -> b19ffe9d5
This update enables struts to be used as JBoss AS 7/WildFly 8/JBoss EAP 6 module.
Project: http://git-wip-us.apache.org/repos/asf/struts/repo
Commit: http://git-wip-us.apache.org/repos/asf/struts/commit/2de0f4b5
Tree: http://git-wip-us.apache.org/repos/asf/struts/tree/2de0f4b5
Diff: http://git-wip-us.apache.org/repos/asf/struts/diff/2de0f4b5
Branch: refs/heads/develop
Commit: 2de0f4b5b10627c53f85a895d310fdaa53c0d2b0
Parents: d2663ce
Author: Luigi Fugaro <l....@gmail.com>
Authored: Tue Jul 29 17:44:28 2014 +0200
Committer: Luigi Fugaro <l....@gmail.com>
Committed: Tue Jul 29 17:44:28 2014 +0200
----------------------------------------------------------------------
.../xwork2/util/LocalizedTextUtil.java | 51 +++++++++++---------
1 file changed, 27 insertions(+), 24 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/struts/blob/2de0f4b5/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 8256cfb..dae9925 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
@@ -38,7 +38,6 @@ import java.text.MessageFormat;
import java.util.*;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;
-import java.util.concurrent.CopyOnWriteArrayList;
/**
@@ -87,7 +86,8 @@ import java.util.concurrent.CopyOnWriteArrayList;
*/
public class LocalizedTextUtil {
- private static final List<String> DEFAULT_RESOURCE_BUNDLES = new CopyOnWriteArrayList<String>();
+ private static final ConcurrentMap<Integer, List<String>> classLoaderMap = new ConcurrentHashMap<Integer, List<String>>();
+// private static final List<String> DEFAULT_RESOURCE_BUNDLES = new CopyOnWriteArrayList<String>();
private static final Logger LOG = LoggerFactory.getLogger(LocalizedTextUtil.class);
private static boolean reloadBundles = false;
private static final ResourceBundle EMPTY_BUNDLE = new EmptyResourceBundle();
@@ -96,6 +96,7 @@ public class LocalizedTextUtil {
private static ClassLoader delegatedClassLoader;
private static final String RELOADED = "com.opensymphony.xwork2.util.LocalizedTextUtil.reloaded";
+ private static final String XWORK_MESSAGES_BUNDLE = "com/opensymphony/xwork2/xwork-messages";
static {
clearDefaultResourceBundles();
@@ -106,16 +107,12 @@ public class LocalizedTextUtil {
* Clears the internal list of resource bundles.
*/
public static void clearDefaultResourceBundles() {
- if (DEFAULT_RESOURCE_BUNDLES != null) {
- synchronized (DEFAULT_RESOURCE_BUNDLES) {
- DEFAULT_RESOURCE_BUNDLES.clear();
- DEFAULT_RESOURCE_BUNDLES.add("com/opensymphony/xwork2/xwork-messages");
- }
- } else {
- synchronized (DEFAULT_RESOURCE_BUNDLES) {
- DEFAULT_RESOURCE_BUNDLES.add("com/opensymphony/xwork2/xwork-messages");
- }
- }
+// DEFAULT_RESOURCE_BUNDLES.clear();
+// DEFAULT_RESOURCE_BUNDLES.add(XWORK_MESSAGES_BUNDLE);
+ ClassLoader ccl = Thread.currentThread().getContextClassLoader();
+ List<String> bundles = new ArrayList<String>();
+ classLoaderMap.put(ccl.hashCode(), bundles);
+ bundles.add(0, XWORK_MESSAGES_BUNDLE);
}
/**
@@ -136,13 +133,20 @@ public class LocalizedTextUtil {
*/
public static void addDefaultResourceBundle(String resourceBundleName) {
//make sure this doesn't get added more than once
- synchronized (DEFAULT_RESOURCE_BUNDLES) {
- DEFAULT_RESOURCE_BUNDLES.remove(resourceBundleName);
- DEFAULT_RESOURCE_BUNDLES.add(0, resourceBundleName);
+ synchronized (classLoaderMap) {
+ ClassLoader ccl = Thread.currentThread().getContextClassLoader();
+ List<String> bundles = classLoaderMap.get(ccl.hashCode());
+ if (bundles == null) {
+ bundles = new ArrayList<String>();
+ classLoaderMap.put(ccl.hashCode(), bundles);
+ bundles.add(XWORK_MESSAGES_BUNDLE);
+ }
+ bundles.remove(resourceBundleName);
+ bundles.add(0, resourceBundleName);
}
if (LOG.isDebugEnabled()) {
- LOG.debug("Added default resource bundle '" + resourceBundleName + "' to default resource bundles = " + DEFAULT_RESOURCE_BUNDLES);
+ //LOG.debug("Added default resource bundle '" + resourceBundleName + "' to default resource bundles = " + DEFAULT_RESOURCE_BUNDLES);
}
}
@@ -197,7 +201,7 @@ public class LocalizedTextUtil {
* @return a localized message based on the specified key, or null if no localized message can be found for it
*/
public static String findDefaultText(String aTextName, Locale locale) {
- List<String> localList = DEFAULT_RESOURCE_BUNDLES;
+ List<String> localList = classLoaderMap.get(Thread.currentThread().getContextClassLoader().hashCode());
for (String bundleName : localList) {
ResourceBundle bundle = findResourceBundle(bundleName, locale);
@@ -252,26 +256,25 @@ public class LocalizedTextUtil {
if (!bundlesMap.containsKey(key)) {
bundle = ResourceBundle.getBundle(aBundleName, locale, Thread.currentThread().getContextClassLoader());
bundlesMap.putIfAbsent(key, bundle);
+ } else {
+ bundle = bundlesMap.get(key);
}
-
- bundle = bundlesMap.get(key);
} catch (MissingResourceException ex) {
if (delegatedClassLoader != null) {
try {
if (!bundlesMap.containsKey(key)) {
bundle = ResourceBundle.getBundle(aBundleName, locale, delegatedClassLoader);
bundlesMap.putIfAbsent(key, bundle);
+ } else {
+ bundle = bundlesMap.get(key);
}
-
- bundle = bundlesMap.get(key);
-
} catch (MissingResourceException e) {
bundle = EMPTY_BUNDLE;
- bundlesMap.putIfAbsent(key, bundle);
+// bundlesMap.putIfAbsent(key, bundle);
}
} else {
bundle = EMPTY_BUNDLE;
- bundlesMap.putIfAbsent(key, bundle);
+// bundlesMap.putIfAbsent(key, bundle);
}
}
return (bundle == EMPTY_BUNDLE) ? null : bundle;
[06/12] git commit: Updates as stated in PR#20 comments.
Posted by lu...@apache.org.
Updates as stated in PR#20 comments.
Project: http://git-wip-us.apache.org/repos/asf/struts/repo
Commit: http://git-wip-us.apache.org/repos/asf/struts/commit/da9afaf8
Tree: http://git-wip-us.apache.org/repos/asf/struts/tree/da9afaf8
Diff: http://git-wip-us.apache.org/repos/asf/struts/diff/da9afaf8
Branch: refs/heads/develop
Commit: da9afaf84e367f0e195cc8f221778eb798595fb6
Parents: 00f424a
Author: Luigi Fugaro <l....@gmail.com>
Authored: Wed Jul 30 14:29:03 2014 +0200
Committer: Luigi Fugaro <l....@gmail.com>
Committed: Wed Jul 30 14:29:03 2014 +0200
----------------------------------------------------------------------
.../opensymphony/xwork2/util/LocalizedTextUtil.java | 15 +++++++--------
1 file changed, 7 insertions(+), 8 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/struts/blob/da9afaf8/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 953c6b2..4e9d4eb 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,7 +86,7 @@ import java.util.concurrent.ConcurrentMap;
*/
public class LocalizedTextUtil {
- private static final ConcurrentMap<Integer, List<String>> classLoaderMap = new ConcurrentHashMap<Integer, List<String>>();
+ private static final ConcurrentMap<Integer, Set<String>> classLoaderMap = new ConcurrentHashMap<Integer, Set<String>>();
private static final Logger LOG = LoggerFactory.getLogger(LocalizedTextUtil.class);
private static boolean reloadBundles = false;
private static final ConcurrentMap<String, ResourceBundle> bundlesMap = new ConcurrentHashMap<String, ResourceBundle>();
@@ -106,9 +106,9 @@ public class LocalizedTextUtil {
*/
public static void clearDefaultResourceBundles() {
ClassLoader ccl = getCurrentThreadContextClassLoader();
- List<String> bundles = new ArrayList<String>();
+ Set<String> bundles = new HashSet<String>();
classLoaderMap.put(ccl.hashCode(), bundles);
- bundles.add(0, XWORK_MESSAGES_BUNDLE);
+ bundles.add(XWORK_MESSAGES_BUNDLE);
}
/**
@@ -132,14 +132,13 @@ public class LocalizedTextUtil {
ClassLoader ccl = null;
synchronized (classLoaderMap) {
ccl = getCurrentThreadContextClassLoader();
- List<String> bundles = classLoaderMap.get(ccl.hashCode());
+ Set<String> bundles = classLoaderMap.get(ccl.hashCode());
if (bundles == null) {
- bundles = new ArrayList<String>();
+ bundles = new HashSet<String>();
classLoaderMap.put(ccl.hashCode(), bundles);
bundles.add(XWORK_MESSAGES_BUNDLE);
}
- bundles.remove(resourceBundleName);
- bundles.add(0, resourceBundleName);
+ bundles.add(resourceBundleName);
}
if (LOG.isDebugEnabled()) {
@@ -198,7 +197,7 @@ public class LocalizedTextUtil {
* @return a localized message based on the specified key, or null if no localized message can be found for it
*/
public static String findDefaultText(String aTextName, Locale locale) {
- List<String> localList = classLoaderMap.get(getCurrentThreadContextClassLoader().hashCode());
+ Set<String> localList = classLoaderMap.get(getCurrentThreadContextClassLoader().hashCode());
for (String bundleName : localList) {
ResourceBundle bundle = findResourceBundle(bundleName, locale);
[05/12] git commit: Updates as stated in PR#20 comments.
Posted by lu...@apache.org.
Updates as stated in PR#20 comments.
Project: http://git-wip-us.apache.org/repos/asf/struts/repo
Commit: http://git-wip-us.apache.org/repos/asf/struts/commit/00f424a3
Tree: http://git-wip-us.apache.org/repos/asf/struts/tree/00f424a3
Diff: http://git-wip-us.apache.org/repos/asf/struts/diff/00f424a3
Branch: refs/heads/develop
Commit: 00f424a3f6a36d75bb32bcbd5e9b95971fb88e7a
Parents: d65270b
Author: Luigi Fugaro <l....@gmail.com>
Authored: Wed Jul 30 12:42:47 2014 +0200
Committer: Luigi Fugaro <l....@gmail.com>
Committed: Wed Jul 30 12:42:47 2014 +0200
----------------------------------------------------------------------
.../xwork2/util/LocalizedTextUtil.java | 27 ++++++++++----------
1 file changed, 13 insertions(+), 14 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/struts/blob/00f424a3/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 dbaef27..953c6b2 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
@@ -105,7 +105,7 @@ public class LocalizedTextUtil {
* Clears the internal list of resource bundles.
*/
public static void clearDefaultResourceBundles() {
- ClassLoader ccl = getThreadCurrentThreadGetContextClassLoader();
+ ClassLoader ccl = getCurrentThreadContextClassLoader();
List<String> bundles = new ArrayList<String>();
classLoaderMap.put(ccl.hashCode(), bundles);
bundles.add(0, XWORK_MESSAGES_BUNDLE);
@@ -131,7 +131,7 @@ public class LocalizedTextUtil {
//make sure this doesn't get added more than once
ClassLoader ccl = null;
synchronized (classLoaderMap) {
- ccl = getThreadCurrentThreadGetContextClassLoader();
+ ccl = getCurrentThreadContextClassLoader();
List<String> bundles = classLoaderMap.get(ccl.hashCode());
if (bundles == null) {
bundles = new ArrayList<String>();
@@ -143,7 +143,7 @@ public class LocalizedTextUtil {
}
if (LOG.isDebugEnabled()) {
- LOG.debug("Added default resource bundle '" + resourceBundleName + "' to default resource bundles for the following classloader " + ccl.toString());
+ LOG.debug("Added default resource bundle '{}' to default resource bundles for the following classloader '{}'", resourceBundleName, ccl.toString());
}
}
@@ -198,7 +198,7 @@ public class LocalizedTextUtil {
* @return a localized message based on the specified key, or null if no localized message can be found for it
*/
public static String findDefaultText(String aTextName, Locale locale) {
- List<String> localList = classLoaderMap.get(getThreadCurrentThreadGetContextClassLoader().hashCode());
+ List<String> localList = classLoaderMap.get(getCurrentThreadContextClassLoader().hashCode());
for (String bundleName : localList) {
ResourceBundle bundle = findResourceBundle(bundleName, locale);
@@ -243,14 +243,12 @@ public class LocalizedTextUtil {
* @return the bundle, <tt>null</tt> if not found.
*/
public static ResourceBundle findResourceBundle(String aBundleName, Locale locale) {
- String key = createMissesKey(aBundleName, locale);
ResourceBundle bundle = null;
- ClassLoader classLoader = getThreadCurrentThreadGetContextClassLoader();
+ ClassLoader classLoader = getCurrentThreadContextClassLoader();
+ String key = createMissesKey(String.valueOf(classLoader.hashCode()), aBundleName, locale);
try {
- key = classLoader.hashCode()+key;
-
if (!bundlesMap.containsKey(key)) {
bundle = ResourceBundle.getBundle(aBundleName, locale, classLoader);
bundlesMap.putIfAbsent(key, bundle);
@@ -280,7 +278,7 @@ public class LocalizedTextUtil {
*/
public static void setDelegatedClassLoader(final ClassLoader classLoader) {
synchronized (bundlesMap) {
- delegatedClassLoaderMap.put(getThreadCurrentThreadGetContextClassLoader().hashCode(), classLoader);
+ delegatedClassLoaderMap.put(getCurrentThreadContextClassLoader().hashCode(), classLoader);
}
}
@@ -290,19 +288,20 @@ public class LocalizedTextUtil {
* @param bundleName
*/
public static void clearBundle(final String bundleName) {
- bundlesMap.remove(getThreadCurrentThreadGetContextClassLoader().hashCode() + bundleName);
+ bundlesMap.remove(getCurrentThreadContextClassLoader().hashCode() + bundleName);
}
/**
* Creates a key to used for lookup/storing in the bundle misses cache.
*
+ * @param prefix the prefix for the returning String - it is supposed to be the ClassLoader hash code.
* @param aBundleName the name of the bundle (usually it's FQN classname).
* @param locale the locale.
* @return the key to use for lookup/storing in the bundle misses cache.
*/
- private static String createMissesKey(String aBundleName, Locale locale) {
- return aBundleName + "_" + locale.toString();
+ private static String createMissesKey(String prefix, String aBundleName, Locale locale) {
+ return prefix + aBundleName + "_" + locale.toString();
}
/**
@@ -812,7 +811,7 @@ public class LocalizedTextUtil {
private static void clearTomcatCache() {
- ClassLoader loader = getThreadCurrentThreadGetContextClassLoader();
+ ClassLoader loader = getCurrentThreadContextClassLoader();
// no need for compilation here.
Class cl = loader.getClass();
@@ -889,7 +888,7 @@ public class LocalizedTextUtil {
}
}
- private static ClassLoader getThreadCurrentThreadGetContextClassLoader() {
+ private static ClassLoader getCurrentThreadContextClassLoader() {
return Thread.currentThread().getContextClassLoader();
}
[03/12] git commit: Removed unused code, comments and variables. Also,
added delegatedClassLoaderMap to handle delegatedClassLoader as per
Tomcat.
Posted by lu...@apache.org.
Removed unused code, comments and variables. Also, added delegatedClassLoaderMap to handle delegatedClassLoader as per Tomcat.
Project: http://git-wip-us.apache.org/repos/asf/struts/repo
Commit: http://git-wip-us.apache.org/repos/asf/struts/commit/c826d97c
Tree: http://git-wip-us.apache.org/repos/asf/struts/tree/c826d97c
Diff: http://git-wip-us.apache.org/repos/asf/struts/diff/c826d97c
Branch: refs/heads/develop
Commit: c826d97cafafc9ce54e15745b23cd211e233c2fa
Parents: 4586d1f
Author: Luigi Fugaro <l....@gmail.com>
Authored: Tue Jul 29 18:44:50 2014 +0200
Committer: Luigi Fugaro <l....@gmail.com>
Committed: Tue Jul 29 18:44:50 2014 +0200
----------------------------------------------------------------------
.../xwork2/util/LocalizedTextUtil.java | 45 +++++++++-----------
1 file changed, 21 insertions(+), 24 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/struts/blob/c826d97c/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 dae9925..dbaef27 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
@@ -87,14 +87,12 @@ import java.util.concurrent.ConcurrentMap;
public class LocalizedTextUtil {
private static final ConcurrentMap<Integer, List<String>> classLoaderMap = new ConcurrentHashMap<Integer, List<String>>();
-// private static final List<String> DEFAULT_RESOURCE_BUNDLES = new CopyOnWriteArrayList<String>();
private static final Logger LOG = LoggerFactory.getLogger(LocalizedTextUtil.class);
private static boolean reloadBundles = false;
- private static final ResourceBundle EMPTY_BUNDLE = new EmptyResourceBundle();
private static final ConcurrentMap<String, ResourceBundle> bundlesMap = new ConcurrentHashMap<String, ResourceBundle>();
private static final ConcurrentMap<MessageFormatKey, MessageFormat> messageFormats = new ConcurrentHashMap<MessageFormatKey, MessageFormat>();
+ private static final ConcurrentMap<Integer, ClassLoader> delegatedClassLoaderMap = new ConcurrentHashMap<Integer, ClassLoader>();
- private static ClassLoader delegatedClassLoader;
private static final String RELOADED = "com.opensymphony.xwork2.util.LocalizedTextUtil.reloaded";
private static final String XWORK_MESSAGES_BUNDLE = "com/opensymphony/xwork2/xwork-messages";
@@ -107,9 +105,7 @@ public class LocalizedTextUtil {
* Clears the internal list of resource bundles.
*/
public static void clearDefaultResourceBundles() {
-// DEFAULT_RESOURCE_BUNDLES.clear();
-// DEFAULT_RESOURCE_BUNDLES.add(XWORK_MESSAGES_BUNDLE);
- ClassLoader ccl = Thread.currentThread().getContextClassLoader();
+ ClassLoader ccl = getThreadCurrentThreadGetContextClassLoader();
List<String> bundles = new ArrayList<String>();
classLoaderMap.put(ccl.hashCode(), bundles);
bundles.add(0, XWORK_MESSAGES_BUNDLE);
@@ -133,8 +129,9 @@ public class LocalizedTextUtil {
*/
public static void addDefaultResourceBundle(String resourceBundleName) {
//make sure this doesn't get added more than once
+ ClassLoader ccl = null;
synchronized (classLoaderMap) {
- ClassLoader ccl = Thread.currentThread().getContextClassLoader();
+ ccl = getThreadCurrentThreadGetContextClassLoader();
List<String> bundles = classLoaderMap.get(ccl.hashCode());
if (bundles == null) {
bundles = new ArrayList<String>();
@@ -146,7 +143,7 @@ public class LocalizedTextUtil {
}
if (LOG.isDebugEnabled()) {
- //LOG.debug("Added default resource bundle '" + resourceBundleName + "' to default resource bundles = " + DEFAULT_RESOURCE_BUNDLES);
+ LOG.debug("Added default resource bundle '" + resourceBundleName + "' to default resource bundles for the following classloader " + ccl.toString());
}
}
@@ -201,7 +198,7 @@ public class LocalizedTextUtil {
* @return a localized message based on the specified key, or null if no localized message can be found for it
*/
public static String findDefaultText(String aTextName, Locale locale) {
- List<String> localList = classLoaderMap.get(Thread.currentThread().getContextClassLoader().hashCode());
+ List<String> localList = classLoaderMap.get(getThreadCurrentThreadGetContextClassLoader().hashCode());
for (String bundleName : localList) {
ResourceBundle bundle = findResourceBundle(bundleName, locale);
@@ -240,8 +237,6 @@ public class LocalizedTextUtil {
* Finds the given resorce bundle by it's name.
* <p/>
* Will use <code>Thread.currentThread().getContextClassLoader()</code> as the classloader.
- * If {@link #delegatedClassLoader} is defined and the bundle cannot be found the current
- * classloader it will delegate to that.
*
* @param aBundleName the name of the bundle (usually it's FQN classname).
* @param locale the locale.
@@ -250,34 +245,32 @@ public class LocalizedTextUtil {
public static ResourceBundle findResourceBundle(String aBundleName, Locale locale) {
String key = createMissesKey(aBundleName, locale);
- ResourceBundle bundle;
+ ResourceBundle bundle = null;
+ ClassLoader classLoader = getThreadCurrentThreadGetContextClassLoader();
try {
+ key = classLoader.hashCode()+key;
+
if (!bundlesMap.containsKey(key)) {
- bundle = ResourceBundle.getBundle(aBundleName, locale, Thread.currentThread().getContextClassLoader());
+ bundle = ResourceBundle.getBundle(aBundleName, locale, classLoader);
bundlesMap.putIfAbsent(key, bundle);
} else {
bundle = bundlesMap.get(key);
}
} catch (MissingResourceException ex) {
- if (delegatedClassLoader != null) {
+ if (delegatedClassLoaderMap.containsKey(classLoader.hashCode())) {
try {
if (!bundlesMap.containsKey(key)) {
- bundle = ResourceBundle.getBundle(aBundleName, locale, delegatedClassLoader);
+ bundle = ResourceBundle.getBundle(aBundleName, locale, delegatedClassLoaderMap.get(classLoader.hashCode()));
bundlesMap.putIfAbsent(key, bundle);
} else {
bundle = bundlesMap.get(key);
}
} catch (MissingResourceException e) {
- bundle = EMPTY_BUNDLE;
-// bundlesMap.putIfAbsent(key, bundle);
}
- } else {
- bundle = EMPTY_BUNDLE;
-// bundlesMap.putIfAbsent(key, bundle);
}
}
- return (bundle == EMPTY_BUNDLE) ? null : bundle;
+ return bundle;
}
/**
@@ -287,7 +280,7 @@ public class LocalizedTextUtil {
*/
public static void setDelegatedClassLoader(final ClassLoader classLoader) {
synchronized (bundlesMap) {
- delegatedClassLoader = classLoader;
+ delegatedClassLoaderMap.put(getThreadCurrentThreadGetContextClassLoader().hashCode(), classLoader);
}
}
@@ -297,7 +290,7 @@ public class LocalizedTextUtil {
* @param bundleName
*/
public static void clearBundle(final String bundleName) {
- bundlesMap.remove(bundleName);
+ bundlesMap.remove(getThreadCurrentThreadGetContextClassLoader().hashCode() + bundleName);
}
@@ -819,7 +812,7 @@ public class LocalizedTextUtil {
private static void clearTomcatCache() {
- ClassLoader loader = Thread.currentThread().getContextClassLoader();
+ ClassLoader loader = getThreadCurrentThreadGetContextClassLoader();
// no need for compilation here.
Class cl = loader.getClass();
@@ -896,6 +889,10 @@ public class LocalizedTextUtil {
}
}
+ private static ClassLoader getThreadCurrentThreadGetContextClassLoader() {
+ return Thread.currentThread().getContextClassLoader();
+ }
+
static class GetDefaultMessageReturnArg {
String message;
boolean foundInBundle;
[02/12] git commit: Added pom's version as 2.3.16.4-SNAPSHOT
Posted by lu...@apache.org.
Added pom's version as 2.3.16.4-SNAPSHOT
Project: http://git-wip-us.apache.org/repos/asf/struts/repo
Commit: http://git-wip-us.apache.org/repos/asf/struts/commit/4586d1f1
Tree: http://git-wip-us.apache.org/repos/asf/struts/tree/4586d1f1
Diff: http://git-wip-us.apache.org/repos/asf/struts/diff/4586d1f1
Branch: refs/heads/develop
Commit: 4586d1f148ef43c7582038306a626144c75d0e49
Parents: 2de0f4b
Author: Luigi Fugaro <l....@gmail.com>
Authored: Tue Jul 29 17:46:04 2014 +0200
Committer: Luigi Fugaro <l....@gmail.com>
Committed: Tue Jul 29 17:46:04 2014 +0200
----------------------------------------------------------------------
xwork-core/pom.xml | 1 +
1 file changed, 1 insertion(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/struts/blob/4586d1f1/xwork-core/pom.xml
----------------------------------------------------------------------
diff --git a/xwork-core/pom.xml b/xwork-core/pom.xml
index 710f635..aac5da0 100644
--- a/xwork-core/pom.xml
+++ b/xwork-core/pom.xml
@@ -10,6 +10,7 @@
<groupId>org.apache.struts.xwork</groupId>
<artifactId>xwork-core</artifactId>
+ <version>2.3.16.4-SNAPSHOT</version>
<packaging>jar</packaging>
<name>XWork: Core</name>
[09/12] git commit: Added the FIXME notation
Posted by lu...@apache.org.
Added the FIXME notation
Project: http://git-wip-us.apache.org/repos/asf/struts/repo
Commit: http://git-wip-us.apache.org/repos/asf/struts/commit/be720106
Tree: http://git-wip-us.apache.org/repos/asf/struts/tree/be720106
Diff: http://git-wip-us.apache.org/repos/asf/struts/diff/be720106
Branch: refs/heads/develop
Commit: be7201062b472b3328ed6ae008997ce1d03d19a9
Parents: 939a3e2
Author: Luigi Fugaro <l....@gmail.com>
Authored: Tue Aug 5 15:48:12 2014 +0200
Committer: Luigi Fugaro <l....@gmail.com>
Committed: Tue Aug 5 15:48:12 2014 +0200
----------------------------------------------------------------------
.../java/com/opensymphony/xwork2/util/LocalizedTextUtilTest.java | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/struts/blob/be720106/xwork-core/src/test/java/com/opensymphony/xwork2/util/LocalizedTextUtilTest.java
----------------------------------------------------------------------
diff --git a/xwork-core/src/test/java/com/opensymphony/xwork2/util/LocalizedTextUtilTest.java b/xwork-core/src/test/java/com/opensymphony/xwork2/util/LocalizedTextUtilTest.java
index 2298297..02e493d 100644
--- a/xwork-core/src/test/java/com/opensymphony/xwork2/util/LocalizedTextUtilTest.java
+++ b/xwork-core/src/test/java/com/opensymphony/xwork2/util/LocalizedTextUtilTest.java
@@ -133,7 +133,7 @@ public class LocalizedTextUtilTest extends XWorkTestCase {
assertEquals("Error during Action invocation", message);
}
- /*
+ /* FIXME
Stated that property's management does not care about ordering,
in fact it's held by a Set instead of List,
you cannot override a previous bundle, thus the test is wrong.
[11/12] git commit: Previous commit restored the ordering feature,
thus testFindTextInChildProperty test also has been restored.
Posted by lu...@apache.org.
Previous commit restored the ordering feature, thus testFindTextInChildProperty test also has been restored.
Project: http://git-wip-us.apache.org/repos/asf/struts/repo
Commit: http://git-wip-us.apache.org/repos/asf/struts/commit/685bb1d0
Tree: http://git-wip-us.apache.org/repos/asf/struts/tree/685bb1d0
Diff: http://git-wip-us.apache.org/repos/asf/struts/diff/685bb1d0
Branch: refs/heads/develop
Commit: 685bb1d069623d59103187d7fee4671e31c353cb
Parents: c74f283
Author: Luigi Fugaro <l....@gmail.com>
Authored: Mon Aug 18 16:27:13 2014 +0200
Committer: Luigi Fugaro <l....@gmail.com>
Committed: Mon Aug 18 16:27:13 2014 +0200
----------------------------------------------------------------------
.../com/opensymphony/xwork2/util/LocalizedTextUtilTest.java | 6 ------
1 file changed, 6 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/struts/blob/685bb1d0/xwork-core/src/test/java/com/opensymphony/xwork2/util/LocalizedTextUtilTest.java
----------------------------------------------------------------------
diff --git a/xwork-core/src/test/java/com/opensymphony/xwork2/util/LocalizedTextUtilTest.java b/xwork-core/src/test/java/com/opensymphony/xwork2/util/LocalizedTextUtilTest.java
index 02e493d..bac41ba 100644
--- a/xwork-core/src/test/java/com/opensymphony/xwork2/util/LocalizedTextUtilTest.java
+++ b/xwork-core/src/test/java/com/opensymphony/xwork2/util/LocalizedTextUtilTest.java
@@ -133,11 +133,6 @@ public class LocalizedTextUtilTest extends XWorkTestCase {
assertEquals("Error during Action invocation", message);
}
- /* FIXME
- Stated that property's management does not care about ordering,
- in fact it's held by a Set instead of List,
- you cannot override a previous bundle, thus the test is wrong.
-
public void testDefaultMessageOverride() throws Exception {
String message = LocalizedTextUtil.findDefaultText(XWorkMessages.ACTION_EXECUTION_ERROR, Locale.getDefault());
assertEquals("Error during Action invocation", message);
@@ -147,7 +142,6 @@ public class LocalizedTextUtilTest extends XWorkTestCase {
message = LocalizedTextUtil.findDefaultText(XWorkMessages.ACTION_EXECUTION_ERROR, Locale.getDefault());
assertEquals("Testing resource bundle override", message);
}
- */
public void testFindTextInChildProperty() throws Exception {
ModelDriven action = new ModelDrivenAction2();
[12/12] git commit: WW-4379 Adds posibility to LocalizedTestUtil by
ClassLoader
Posted by lu...@apache.org.
WW-4379 Adds posibility to LocalizedTestUtil by ClassLoader
Project: http://git-wip-us.apache.org/repos/asf/struts/repo
Commit: http://git-wip-us.apache.org/repos/asf/struts/commit/b19ffe9d
Tree: http://git-wip-us.apache.org/repos/asf/struts/tree/b19ffe9d
Diff: http://git-wip-us.apache.org/repos/asf/struts/diff/b19ffe9d
Branch: refs/heads/develop
Commit: b19ffe9d5964b0dd909bf075810075aa1b0a72a0
Parents: d749bb8 685bb1d
Author: Lukasz Lenart <lu...@apache.org>
Authored: Thu Aug 21 09:44:24 2014 +0200
Committer: Lukasz Lenart <lu...@apache.org>
Committed: Thu Aug 21 09:44:24 2014 +0200
----------------------------------------------------------------------
.../xwork2/util/LocalizedTextUtil.java | 83 ++++++++++----------
1 file changed, 41 insertions(+), 42 deletions(-)
----------------------------------------------------------------------
[08/12] git commit: Updates as stated in PR#20 comments -
synchronized code block inside addDefaultResourceBundle method using
XWORK_MESSAGES_BUNDLE.
Posted by lu...@apache.org.
Updates as stated in PR#20 comments - synchronized code block inside addDefaultResourceBundle method using XWORK_MESSAGES_BUNDLE.
Project: http://git-wip-us.apache.org/repos/asf/struts/repo
Commit: http://git-wip-us.apache.org/repos/asf/struts/commit/939a3e20
Tree: http://git-wip-us.apache.org/repos/asf/struts/tree/939a3e20
Diff: http://git-wip-us.apache.org/repos/asf/struts/diff/939a3e20
Branch: refs/heads/develop
Commit: 939a3e20400d915de809fbd0e304c1bd2fac5813
Parents: 9254aaa
Author: Luigi Fugaro <l....@gmail.com>
Authored: Thu Jul 31 12:08:30 2014 +0200
Committer: Luigi Fugaro <l....@gmail.com>
Committed: Thu Jul 31 12:08:30 2014 +0200
----------------------------------------------------------------------
.../main/java/com/opensymphony/xwork2/util/LocalizedTextUtil.java | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/struts/blob/939a3e20/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 4e9d4eb..3219450 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
@@ -130,7 +130,7 @@ public class LocalizedTextUtil {
public static void addDefaultResourceBundle(String resourceBundleName) {
//make sure this doesn't get added more than once
ClassLoader ccl = null;
- synchronized (classLoaderMap) {
+ synchronized (XWORK_MESSAGES_BUNDLE) {
ccl = getCurrentThreadContextClassLoader();
Set<String> bundles = classLoaderMap.get(ccl.hashCode());
if (bundles == null) {
[04/12] git commit: Deleted internal versioning.
Posted by lu...@apache.org.
Deleted internal versioning.
Project: http://git-wip-us.apache.org/repos/asf/struts/repo
Commit: http://git-wip-us.apache.org/repos/asf/struts/commit/d65270b9
Tree: http://git-wip-us.apache.org/repos/asf/struts/tree/d65270b9
Diff: http://git-wip-us.apache.org/repos/asf/struts/diff/d65270b9
Branch: refs/heads/develop
Commit: d65270b9bb061bf16072e706f53060d3d9ab78ca
Parents: c826d97
Author: Luigi Fugaro <l....@gmail.com>
Authored: Wed Jul 30 11:42:46 2014 +0200
Committer: Luigi Fugaro <l....@gmail.com>
Committed: Wed Jul 30 11:42:46 2014 +0200
----------------------------------------------------------------------
xwork-core/pom.xml | 1 -
1 file changed, 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/struts/blob/d65270b9/xwork-core/pom.xml
----------------------------------------------------------------------
diff --git a/xwork-core/pom.xml b/xwork-core/pom.xml
index aac5da0..710f635 100644
--- a/xwork-core/pom.xml
+++ b/xwork-core/pom.xml
@@ -10,7 +10,6 @@
<groupId>org.apache.struts.xwork</groupId>
<artifactId>xwork-core</artifactId>
- <version>2.3.16.4-SNAPSHOT</version>
<packaging>jar</packaging>
<name>XWork: Core</name>
[10/12] git commit: Restored the ordering feature.
Posted by lu...@apache.org.
Restored the ordering feature.
Project: http://git-wip-us.apache.org/repos/asf/struts/repo
Commit: http://git-wip-us.apache.org/repos/asf/struts/commit/c74f2836
Tree: http://git-wip-us.apache.org/repos/asf/struts/tree/c74f2836
Diff: http://git-wip-us.apache.org/repos/asf/struts/diff/c74f2836
Branch: refs/heads/develop
Commit: c74f283626ac0c08f66e52b6102fcaa3d6614903
Parents: be72010
Author: Luigi Fugaro <l....@gmail.com>
Authored: Mon Aug 18 16:25:42 2014 +0200
Committer: Luigi Fugaro <l....@gmail.com>
Committed: Mon Aug 18 16:25:42 2014 +0200
----------------------------------------------------------------------
.../opensymphony/xwork2/util/LocalizedTextUtil.java | 15 ++++++++-------
1 file changed, 8 insertions(+), 7 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/struts/blob/c74f2836/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 3219450..9aad928 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,7 +86,7 @@ import java.util.concurrent.ConcurrentMap;
*/
public class LocalizedTextUtil {
- private static final ConcurrentMap<Integer, Set<String>> classLoaderMap = new ConcurrentHashMap<Integer, Set<String>>();
+ private static final ConcurrentMap<Integer, List<String>> classLoaderMap = new ConcurrentHashMap<Integer, List<String>>();
private static final Logger LOG = LoggerFactory.getLogger(LocalizedTextUtil.class);
private static boolean reloadBundles = false;
private static final ConcurrentMap<String, ResourceBundle> bundlesMap = new ConcurrentHashMap<String, ResourceBundle>();
@@ -106,9 +106,9 @@ public class LocalizedTextUtil {
*/
public static void clearDefaultResourceBundles() {
ClassLoader ccl = getCurrentThreadContextClassLoader();
- Set<String> bundles = new HashSet<String>();
+ List<String> bundles = new ArrayList<String>();
classLoaderMap.put(ccl.hashCode(), bundles);
- bundles.add(XWORK_MESSAGES_BUNDLE);
+ bundles.add(0, XWORK_MESSAGES_BUNDLE);
}
/**
@@ -132,13 +132,14 @@ public class LocalizedTextUtil {
ClassLoader ccl = null;
synchronized (XWORK_MESSAGES_BUNDLE) {
ccl = getCurrentThreadContextClassLoader();
- Set<String> bundles = classLoaderMap.get(ccl.hashCode());
+ List<String> bundles = classLoaderMap.get(ccl.hashCode());
if (bundles == null) {
- bundles = new HashSet<String>();
+ bundles = new ArrayList<String>();
classLoaderMap.put(ccl.hashCode(), bundles);
bundles.add(XWORK_MESSAGES_BUNDLE);
}
- bundles.add(resourceBundleName);
+ bundles.remove(resourceBundleName);
+ bundles.add(0, resourceBundleName);
}
if (LOG.isDebugEnabled()) {
@@ -197,7 +198,7 @@ public class LocalizedTextUtil {
* @return a localized message based on the specified key, or null if no localized message can be found for it
*/
public static String findDefaultText(String aTextName, Locale locale) {
- Set<String> localList = classLoaderMap.get(getCurrentThreadContextClassLoader().hashCode());
+ List<String> localList = classLoaderMap.get(Thread.currentThread().getContextClassLoader().hashCode());
for (String bundleName : localList) {
ResourceBundle bundle = findResourceBundle(bundleName, locale);
[07/12] git commit: Updates as stated in PR#20 comments - removed
test method testDefaultMessageOverride.
Posted by lu...@apache.org.
Updates as stated in PR#20 comments - removed test method testDefaultMessageOverride.
Project: http://git-wip-us.apache.org/repos/asf/struts/repo
Commit: http://git-wip-us.apache.org/repos/asf/struts/commit/9254aaae
Tree: http://git-wip-us.apache.org/repos/asf/struts/tree/9254aaae
Diff: http://git-wip-us.apache.org/repos/asf/struts/diff/9254aaae
Branch: refs/heads/develop
Commit: 9254aaaefefbf0cc523c1bd710b60b9b815825e2
Parents: da9afaf
Author: Luigi Fugaro <l....@gmail.com>
Authored: Wed Jul 30 14:29:47 2014 +0200
Committer: Luigi Fugaro <l....@gmail.com>
Committed: Wed Jul 30 14:29:47 2014 +0200
----------------------------------------------------------------------
.../com/opensymphony/xwork2/util/LocalizedTextUtilTest.java | 6 ++++++
1 file changed, 6 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/struts/blob/9254aaae/xwork-core/src/test/java/com/opensymphony/xwork2/util/LocalizedTextUtilTest.java
----------------------------------------------------------------------
diff --git a/xwork-core/src/test/java/com/opensymphony/xwork2/util/LocalizedTextUtilTest.java b/xwork-core/src/test/java/com/opensymphony/xwork2/util/LocalizedTextUtilTest.java
index bac41ba..2298297 100644
--- a/xwork-core/src/test/java/com/opensymphony/xwork2/util/LocalizedTextUtilTest.java
+++ b/xwork-core/src/test/java/com/opensymphony/xwork2/util/LocalizedTextUtilTest.java
@@ -133,6 +133,11 @@ public class LocalizedTextUtilTest extends XWorkTestCase {
assertEquals("Error during Action invocation", message);
}
+ /*
+ Stated that property's management does not care about ordering,
+ in fact it's held by a Set instead of List,
+ you cannot override a previous bundle, thus the test is wrong.
+
public void testDefaultMessageOverride() throws Exception {
String message = LocalizedTextUtil.findDefaultText(XWorkMessages.ACTION_EXECUTION_ERROR, Locale.getDefault());
assertEquals("Error during Action invocation", message);
@@ -142,6 +147,7 @@ public class LocalizedTextUtilTest extends XWorkTestCase {
message = LocalizedTextUtil.findDefaultText(XWorkMessages.ACTION_EXECUTION_ERROR, Locale.getDefault());
assertEquals("Testing resource bundle override", message);
}
+ */
public void testFindTextInChildProperty() throws Exception {
ModelDriven action = new ModelDrivenAction2();