Commits

rgielen  committed 5bd28fc

XW-651, WW-2709:
- Fix broken validator xml file loading in Websphere 6 environments, as already exists in trunk

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

  • Participants
  • Parent commits 1b8d81e
  • Branches 2.0, xwork_2_0_7

Comments (0)

Files changed (1)

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

 import java.util.Map;
 import java.net.URL;
 import java.net.URISyntaxException;
+import java.net.URI;
 
 
 /**
             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");
+                try {
+                    URI uri = new URI(u.toExternalForm().replaceAll(" ", "%20"));
+                    if ("file".equalsIgnoreCase(uri.getScheme())) {
+                        File f = new File(uri);
+                        FilenameFilter filter = new FilenameFilter() {
+                            public boolean accept(File file, String fileName) {
+                                return fileName.contains("-validators.xml");
+                            }
+                        };
+                        files.addAll(Arrays.asList(f.listFiles(filter)));
                     }
-                };
-                files.addAll(Arrays.asList(f.listFiles(filter)));
-            }    
-        } catch (URISyntaxException e) {
-            // swallow
+                } catch (Exception ex) {
+                    LOG.error("Unable to load " + u.toString(), ex);
+                }
+            }
         } 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);