geronimo-xbean-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From xiam...@apache.org
Subject svn commit: r1347954 - /geronimo/xbean/trunk/xbean-bundleutils/src/main/java/org/apache/xbean/osgi/bundle/util/BundleUtils.java
Date Fri, 08 Jun 2012 09:08:40 GMT
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;



Mime
View raw message