You are viewing a plain text version of this content. The canonical link for it is here.
Posted to xbean-scm@geronimo.apache.org by xi...@apache.org on 2012/06/08 11:08:40 UTC

svn commit: r1347954 - /geronimo/xbean/trunk/xbean-bundleutils/src/main/java/org/apache/xbean/osgi/bundle/util/BundleUtils.java

Author: xiaming
Date: Fri Jun  8 09:08:40 2012
New Revision: 1347954

URL: http://svn.apache.org/viewvc?rev=1347954&view=rev
Log:
GERONIMO-6358 Revise the fix to endure more special chars cases

Modified:
    geronimo/xbean/trunk/xbean-bundleutils/src/main/java/org/apache/xbean/osgi/bundle/util/BundleUtils.java

Modified: geronimo/xbean/trunk/xbean-bundleutils/src/main/java/org/apache/xbean/osgi/bundle/util/BundleUtils.java
URL: http://svn.apache.org/viewvc/geronimo/xbean/trunk/xbean-bundleutils/src/main/java/org/apache/xbean/osgi/bundle/util/BundleUtils.java?rev=1347954&r1=1347953&r2=1347954&view=diff
==============================================================================
--- geronimo/xbean/trunk/xbean-bundleutils/src/main/java/org/apache/xbean/osgi/bundle/util/BundleUtils.java (original)
+++ geronimo/xbean/trunk/xbean-bundleutils/src/main/java/org/apache/xbean/osgi/bundle/util/BundleUtils.java Fri Jun  8 09:08:40 2012
@@ -272,13 +272,20 @@ public class BundleUtils {
      */
     public static File toFile(String url) {
         if (url !=null && url.startsWith(REFERENCE_FILE_SCHEMA)) {
+            File file = null;
             try {
-                File file = new File(new URL(url.substring(REFERENCE_SCHEME.length())).toURI());
+                file = new File(new URL(url.substring(REFERENCE_SCHEME.length())).toURI());
                 if (file.exists()) {
                     return file;
                 }
             } catch (Exception e) {
-                // TODO: handle exception
+                // If url includes special chars: { } [ ] % < > # ^ ?
+                // URISyntaxException or MalformedURLException will be thrown, 
+                // so try to use File(String) directly
+                file = new File(url.substring(REFERENCE_FILE_SCHEMA.length()));
+                if (file.exists()) {
+                    return file;
+                }
             }
         }
         return null;