Commits

Anonymous committed 2559187

Fixing validation parsing failure

git-svn-id: http://svn.opensymphony.com/svn/xwork/branches/2.0@1710e221344d-f017-0410-9bd5-d282ab1896d7

Comments (0)

Files changed (1)

src/java/com/opensymphony/xwork2/validator/ValidatorFactory.java

 package com.opensymphony.xwork2.validator;
 
 import com.opensymphony.xwork2.util.ClassLoaderUtil;
+import com.opensymphony.xwork2.config.ConfigurationException;
 import com.opensymphony.xwork2.ObjectFactory;
 import com.opensymphony.xwork2.XWorkException;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 
 import java.io.InputStream;
+import java.io.IOException;
 import java.io.File;
 import java.io.FilenameFilter;
+import java.util.Arrays;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
 import java.util.HashMap;
 import java.util.Map;
 import java.net.URL;
         }
 
         // Get custom validator configurations via the classpath
-        URL u = ClassLoaderUtil.getResource("", ValidatorFactory.class);
-        File[] files = null;
+        List<File> files = new ArrayList<File>();
         try {
-            File f = new File(u.toURI());
-            FilenameFilter filter = new FilenameFilter() {
-                public boolean accept(File file, String fileName) {
-                    return fileName.contains("-validators.xml");
-                }
-            };
-            files = f.listFiles(filter);
+            Iterator<URL> urls = ClassLoaderUtil.getResources("", ValidatorFactory.class, false);
+            while (urls.hasNext()) {
+                URL u = urls.next();
+
+                File f = new File(u.toURI());
+                FilenameFilter filter = new FilenameFilter() {
+                    public boolean accept(File file, String fileName) {
+                        return fileName.contains("-validators.xml");
+                    }
+                };
+                files.addAll(Arrays.asList(f.listFiles(filter)));
+            }    
         } catch (URISyntaxException e) {
             // swallow
-        }
-
+        } catch (IOException e) {
+            throw new ConfigurationException("Unable to load validator files", e);
+        }    
+    
         // Parse default validator configurations
         String resourceName = "com/opensymphony/xwork2/validator/validators/default.xml";
         retrieveValidatorConfiguration(resourceName);
         retrieveValidatorConfiguration(resourceName);
 
         // Add custom (plugin) specific validator configurations
-        if ( files != null && files.length > 0 ) {
-            for (File file : files) {
-                retrieveValidatorConfiguration(file.getName());
-            }
+        for (File file : files) {
+            retrieveValidatorConfiguration(file.getName());
         }
     }