db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kmars...@apache.org
Subject svn commit: r1097543 - in /db/derby/code/branches/10.7: ./ java/tools/org/apache/derby/impl/tools/sysinfo/Main.java
Date Thu, 28 Apr 2011 16:48:56 GMT
Author: kmarsden
Date: Thu Apr 28 16:48:56 2011
New Revision: 1097543

URL: http://svn.apache.org/viewvc?rev=1097543&view=rev
Log:
DERBY-4617 Sysinfo.testSysinfoLocale failed with IBM  1.6 on Windows 7 64bit

Wrap getCononicalPath() in sysinfo.



Modified:
    db/derby/code/branches/10.7/   (props changed)
    db/derby/code/branches/10.7/java/tools/org/apache/derby/impl/tools/sysinfo/Main.java

Propchange: db/derby/code/branches/10.7/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Thu Apr 28 16:48:56 2011
@@ -1 +1 @@
-/db/derby/code/trunk:1035603,1036769,1038514,1038813,1039084,1039268,1040658,1041338,1043227,1043389,1044096,1051026,1053724,1055169,1059888,1060480,1062096,1063809,1065061,1066290,1067250,1067357,1069661,1071463,1071886,1076387,1078461,1078693,1081455,1091000
+/db/derby/code/trunk:1035603,1036769,1038514,1038813,1039084,1039268,1040658,1041338,1043227,1043389,1044096,1051026,1053724,1055169,1059888,1060480,1062096,1063809,1065061,1066290,1067250,1067357,1069661,1071463,1071886,1076387,1078461,1078693,1081455,1091000,1097247

Modified: db/derby/code/branches/10.7/java/tools/org/apache/derby/impl/tools/sysinfo/Main.java
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.7/java/tools/org/apache/derby/impl/tools/sysinfo/Main.java?rev=1097543&r1=1097542&r2=1097543&view=diff
==============================================================================
--- db/derby/code/branches/10.7/java/tools/org/apache/derby/impl/tools/sysinfo/Main.java (original)
+++ db/derby/code/branches/10.7/java/tools/org/apache/derby/impl/tools/sysinfo/Main.java Thu
Apr 28 16:48:56 2011
@@ -44,6 +44,8 @@ import java.io.InputStream;
 import java.lang.reflect.Method;
 import java.net.URL;
 import java.net.URLDecoder;
+import java.security.PrivilegedActionException;
+import java.security.PrivilegedExceptionAction;
 import java.security.ProtectionDomain;
 import java.security.CodeSource;
 import java.security.AccessController;
@@ -366,6 +368,29 @@ public static void getMainInfo (java.io.
   } // end of getJavaProperty (String whichProperty)
 
 
+    /**
+     * wrapper for getCanonicalPath for sysinfo. For sysinfo we just want to print
+     * the security exceptions, not throw them if we don't have permmission
+     * 
+     * @param f file on which to call getCanonicalPath
+     * @return f.getCanonicalPath
+     * @throws IOException
+     */
+    private static String getCanonicalPath(final File f) throws IOException {
+
+        try {
+            return (String) AccessController
+                    .doPrivileged(new PrivilegedExceptionAction() {
+                        public Object run() throws IOException {
+                            return f.getCanonicalPath();
+                        }
+                    });
+        } catch (PrivilegedActionException pae) {
+            throw (IOException) pae.getCause();
+        } catch (SecurityException se) {
+            return Main.getTextMessage("SIF01.I", se);
+        }
+    }
 
   /**
     for use by the main () method
@@ -999,7 +1024,7 @@ public static void getMainInfo (java.io.
             InputStream bis = new FileInputStream(f);
 
             ZipInfoProperties zip = new ZipInfoProperties(ProductVersionHolder.getProductVersionHolderFromMyEnv(bis));
-            zip.setLocation(new File(dirname).getCanonicalPath().replace('/', File.separatorChar));
+            zip.setLocation(getCanonicalPath(new File(dirname)).replace('/', File.separatorChar));
             return zip;
         }
         catch (IOException ioe)
@@ -1048,7 +1073,7 @@ public static void getMainInfo (java.io.
             }
 
             ZipInfoProperties zip = new ZipInfoProperties(ProductVersionHolder.getProductVersionHolderFromMyEnv(bis));
-            zip.setLocation(new File(filename).getCanonicalPath().replace('/', File.separatorChar));
+            zip.setLocation(getCanonicalPath(new File(filename)).replace('/', File.separatorChar));
             return zip;
 
         }
@@ -1221,7 +1246,7 @@ public static void getMainInfo (java.io.
 
         String result = ""; 
         try {
-            result = new File(filename).getCanonicalPath().replace('/', File.separatorChar);
+            result = getCanonicalPath(new File(filename)).replace('/', File.separatorChar);
         } catch (IOException e) {
             result = e.getMessage();
         }



Mime
View raw message