struts-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Dale Newfield <D...@Newfield.org>
Subject Re: [struts-dev] classpath issues...
Date Sat, 07 Jun 2008 17:58:20 GMT
Struts Two wrote:
> Hi:
> I think this is because an existing bug in struts 2. I have been experienceing the same
issue for sometime. There are two JIRA issues opened for this. You can refer to : WW-2633
and WW-2642 .

My problem appears to be related to yours, but with a different source. 
  Both are due to urls that this code can't handle, but those urls have 
different sources.  The following patch both extends Musachy's detection 
to detect my issue as well, and adds a try/catch block so that any 
exception thrown because of a URI that File cannot handle is swallowed 
and the processing continues.  I would like to find the source of the 
bad url, but this patch to xwork will at least prevent that bad url from 
being a showstopper for me.

So, should I just add this patch to WW-2633, or should I open a new issue?

-Dale

Index: 
src/java/com/opensymphony/xwork2/validator/DefaultValidatorFactory.java
===================================================================
--- 
src/java/com/opensymphony/xwork2/validator/DefaultValidatorFactory.java 
     (revision 1783)
+++ 
src/java/com/opensymphony/xwork2/validator/DefaultValidatorFactory.java 
     (working copy)
@@ -98,8 +98,9 @@
              Iterator<URL> urls = ClassLoaderUtil.getResources("", 
DefaultValidatorFactory.class, false);
              while (urls.hasNext()) {
                  URL u = urls.next();
+                try {
                  URI uri = new URI(u.toExternalForm().replaceAll(" ", 
"%20"));
-                if ("file".equalsIgnoreCase(uri.getScheme())) {
+                    if (!uri.isOpaque() && 
"file".equalsIgnoreCase(uri.getScheme())) {
                      File f = new File(uri);
                      FilenameFilter filter = new FilenameFilter() {
                          public boolean accept(File file, String 
fileName) {
@@ -108,6 +109,10 @@
                      };
                      files.addAll(Arrays.asList(f.listFiles(filter)));
                  }
+                } catch (IllegalArgumentException e) {
+                  e.printStackTrace();
+                  // swallow
+                }
              }
          } catch (URISyntaxException e) {
              e.printStackTrace();

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@struts.apache.org
For additional commands, e-mail: dev-help@struts.apache.org


Mime
View raw message