db-derby-commits mailing list archives

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

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

Propchange: db/derby/code/branches/10.8/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Thu Apr 28 16:26:32 2011
@@ -1,2 +1,2 @@
 /db/derby/code/branches/10.7:1061570,1061578,1082235
-/db/derby/code/trunk:1063809,1088633,1091000,1091221,1091285,1092067,1092795,1094315,1094572,1094728,1096741,1096890,1097460,1097469,1097471
+/db/derby/code/trunk:1063809,1088633,1091000,1091221,1091285,1092067,1092795,1094315,1094572,1094728,1096741,1096890,1097247,1097249,1097460,1097469,1097471

Modified: db/derby/code/branches/10.8/java/tools/org/apache/derby/impl/tools/sysinfo/Main.java
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.8/java/tools/org/apache/derby/impl/tools/sysinfo/Main.java?rev=1097535&r1=1097534&r2=1097535&view=diff
==============================================================================
--- db/derby/code/branches/10.8/java/tools/org/apache/derby/impl/tools/sysinfo/Main.java (original)
+++ db/derby/code/branches/10.8/java/tools/org/apache/derby/impl/tools/sysinfo/Main.java Thu
Apr 28 16:26:32 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