struts-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From lukaszlen...@apache.org
Subject svn commit: r1364079 - in /struts/struts2/trunk/xwork-core/src: main/java/com/opensymphony/xwork2/validator/DefaultActionValidatorManager.java test/java/com/opensymphony/xwork2/validator/DefaultActionValidatorManagerTest.java
Date Sat, 21 Jul 2012 13:12:49 GMT
Author: lukaszlenart
Date: Sat Jul 21 13:12:48 2012
New Revision: 1364079

URL: http://svn.apache.org/viewvc?rev=1364079&view=rev
Log:
WW-3850 solves problem with NPE when ActionValidationManager is trying to load Object-validation.xml

Modified:
    struts/struts2/trunk/xwork-core/src/main/java/com/opensymphony/xwork2/validator/DefaultActionValidatorManager.java
    struts/struts2/trunk/xwork-core/src/test/java/com/opensymphony/xwork2/validator/DefaultActionValidatorManagerTest.java

Modified: struts/struts2/trunk/xwork-core/src/main/java/com/opensymphony/xwork2/validator/DefaultActionValidatorManager.java
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/xwork-core/src/main/java/com/opensymphony/xwork2/validator/DefaultActionValidatorManager.java?rev=1364079&r1=1364078&r2=1364079&view=diff
==============================================================================
--- struts/struts2/trunk/xwork-core/src/main/java/com/opensymphony/xwork2/validator/DefaultActionValidatorManager.java
(original)
+++ struts/struts2/trunk/xwork-core/src/main/java/com/opensymphony/xwork2/validator/DefaultActionValidatorManager.java
Sat Jul 21 13:12:48 2012
@@ -328,7 +328,7 @@ public class DefaultActionValidatorManag
     private List<ValidatorConfig> loadFile(String fileName, Class clazz, boolean checkFile)
{
         List<ValidatorConfig> retList = Collections.emptyList();
         URL fileUrl = ClassLoaderUtil.getResource(fileName, clazz);
-        if ((checkFile && fileManager.fileNeedsReloading(fileUrl.toString())) ||
!validatorFileCache.containsKey(fileName)) {
+        if ((checkFile && fileUrl != null && fileManager.fileNeedsReloading(fileUrl.toString()))
|| !validatorFileCache.containsKey(fileName)) {
             InputStream is = null;
 
             try {

Modified: struts/struts2/trunk/xwork-core/src/test/java/com/opensymphony/xwork2/validator/DefaultActionValidatorManagerTest.java
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/xwork-core/src/test/java/com/opensymphony/xwork2/validator/DefaultActionValidatorManagerTest.java?rev=1364079&r1=1364078&r2=1364079&view=diff
==============================================================================
--- struts/struts2/trunk/xwork-core/src/test/java/com/opensymphony/xwork2/validator/DefaultActionValidatorManagerTest.java
(original)
+++ struts/struts2/trunk/xwork-core/src/test/java/com/opensymphony/xwork2/validator/DefaultActionValidatorManagerTest.java
Sat Jul 21 13:12:48 2012
@@ -18,6 +18,7 @@ package com.opensymphony.xwork2.validato
 import com.mockobjects.dynamic.C;
 import com.mockobjects.dynamic.Mock;
 import com.opensymphony.xwork2.ActionContext;
+import com.opensymphony.xwork2.FileManagerFactory;
 import com.opensymphony.xwork2.SimpleAction;
 import com.opensymphony.xwork2.StubValueStack;
 import com.opensymphony.xwork2.TestBean;
@@ -164,6 +165,25 @@ public class DefaultActionValidatorManag
         mockValidatorFileParser.verify();
     }
 
+    /**
+     * Test to verify WW-3850.
+     *
+     * @since 2.3.5
+     */
+    public void testBuildsValidatorsForClassError() {
+        // for this test we need to have a file manager with reloadingConfigs to true
+        container.getInstance(FileManagerFactory.class).getFileManager().setReloadingConfigs("true");
+        // no validator found, but no check on file since it is not in cache
+        actionValidatorManager.getValidators(List.class, null);
+        // this second call will try reload a not existing file
+        // and causes a NPE (see WW-3850)
+        try {
+            actionValidatorManager.getValidators(List.class, null);
+        } catch (Exception e) {
+            fail("Exception occurred " + e);
+        }
+    }
+
     /*
     // TODO: this all need to be converted to real unit tests
 



Mime
View raw message