db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kmars...@apache.org
Subject svn commit: r1097550 - in /db/derby/code/branches/10.6: ./ java/tools/org/apache/derby/impl/tools/sysinfo/Main.java
Date Thu, 28 Apr 2011 17:09:58 GMT
Author: kmarsden
Date: Thu Apr 28 17:09:58 2011
New Revision: 1097550

URL: http://svn.apache.org/viewvc?rev=1097550&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.6/   (props changed)
    db/derby/code/branches/10.6/java/tools/org/apache/derby/impl/tools/sysinfo/Main.java

Propchange: db/derby/code/branches/10.6/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Thu Apr 28 17:09:58 2011
@@ -1,2 +1,2 @@
-/db/derby/code/trunk:938547,938796,938959,939231,940462,940469,941627,942031,942286,942476,942480,942587,944152,946794,948045,948069,951346,951366,952138,952237,952581,954344,954421,954544,954748,955001,955540,955634,956075,956234,956445,956569,956659,957260,957902,958163,958257,958264,958508,958522,958555,958618,958939,959550,961892,962716,963206,963705,964039,964115,964402,965647,966393,967201,967304,980089,980684,986689,986834,987539,989099,990292,997325,998170,999119,999479,999485,1002291,1002682,1002853,1021426,1024511,1024528,1025615,1025795,1028716,1030043,1033485,1033864,1035164,1038514,1040658,1053724,1055169,1062096,1063809,1065061,1067250,1069661,1071886,1078461,1081455
+/db/derby/code/trunk:938547,938796,938959,939231,940462,940469,941627,942031,942286,942476,942480,942587,944152,946794,948045,948069,951346,951366,952138,952237,952581,954344,954421,954544,954748,955001,955540,955634,956075,956234,956445,956569,956659,957260,957902,958163,958257,958264,958508,958522,958555,958618,958939,959550,961892,962716,963206,963705,964039,964115,964402,965647,966393,967201,967304,980089,980684,986689,986834,987539,989099,990292,997325,998170,999119,999479,999485,1002291,1002682,1002853,1021426,1024511,1024528,1025615,1025795,1028716,1030043,1033485,1033864,1035164,1038514,1040658,1053724,1055169,1062096,1063809,1065061,1067250,1069661,1071886,1078461,1081455,1097247
 /db/derby/docs/trunk:954344

Modified: db/derby/code/branches/10.6/java/tools/org/apache/derby/impl/tools/sysinfo/Main.java
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.6/java/tools/org/apache/derby/impl/tools/sysinfo/Main.java?rev=1097550&r1=1097549&r2=1097550&view=diff
==============================================================================
--- db/derby/code/branches/10.6/java/tools/org/apache/derby/impl/tools/sysinfo/Main.java (original)
+++ db/derby/code/branches/10.6/java/tools/org/apache/derby/impl/tools/sysinfo/Main.java Thu
Apr 28 17:09:58 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
@@ -1000,7 +1025,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)
@@ -1049,7 +1074,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;
 
         }
@@ -1222,7 +1247,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