Commits

Anonymous committed 8c287b3

Better handling of locale lookups, synchronized class cache lookups for spring

git-svn-id: http://svn.opensymphony.com/svn/xwork/trunk@1612e221344d-f017-0410-9bd5-d282ab1896d7

Comments (0)

Files changed (2)

src/java/com/opensymphony/xwork2/ActionSupport.java

     }
 
     public Locale getLocale() {
-        return ActionContext.getContext().getLocale();
+        ActionContext ctx = ActionContext.getContext();
+        if (ctx != null) {
+            return ctx.getLocale();
+        } else {
+            LOG.debug("Action context not initialized");
+            return null;
+        }
     }
 
     public String getText(String aTextName) {

src/java/com/opensymphony/xwork2/spring/SpringObjectFactory.java

     public Class getClassInstance(String className) throws ClassNotFoundException {
         Class clazz = null;
         if (useClassCache) {
-            // this cache of classes is needed because Spring sucks at dealing with situations where the
-            // class instance changes 
-            clazz = (Class) classes.get(className);
+            synchronized(classes) {
+                // this cache of classes is needed because Spring sucks at dealing with situations where the
+                // class instance changes 
+                clazz = (Class) classes.get(className);
+            }
         }
 
         if (clazz == null) {
             }
 
             if (useClassCache) {
-                classes.put(className, clazz);
+                synchronized(classes) {
+                    classes.put(className, clazz);
+                }
             }
         }