You are viewing a plain text version of this content. The canonical link for it is here.
Posted to derby-commits@db.apache.org by km...@apache.org on 2007/06/07 19:50:37 UTC
svn commit: r545251 -
/db/derby/code/trunk/java/client/org/apache/derby/jdbc/ClientBaseDataSource.java
Author: kmarsden
Date: Thu Jun 7 10:50:36 2007
New Revision: 545251
URL: http://svn.apache.org/viewvc?view=rev&rev=545251
Log:
DERBY-2754 Client connections should not fail if permission is not granted to read derby.client.traceLevel and derby.client.traceDirectory
Ignore properties if there is no permission to read them.
Modified:
db/derby/code/trunk/java/client/org/apache/derby/jdbc/ClientBaseDataSource.java
Modified: db/derby/code/trunk/java/client/org/apache/derby/jdbc/ClientBaseDataSource.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/client/org/apache/derby/jdbc/ClientBaseDataSource.java?view=diff&rev=545251&r1=545250&r2=545251
==============================================================================
--- db/derby/code/trunk/java/client/org/apache/derby/jdbc/ClientBaseDataSource.java (original)
+++ db/derby/code/trunk/java/client/org/apache/derby/jdbc/ClientBaseDataSource.java Thu Jun 7 10:50:36 2007
@@ -25,6 +25,7 @@
import java.io.PrintWriter;
import java.io.File;
import java.security.AccessController;
+import java.security.PrivilegedActionException;
import java.util.Properties;
import java.util.StringTokenizer;
import java.util.NoSuchElementException;
@@ -379,17 +380,20 @@
*/
public static String getTraceDirectory(Properties properties) {
String traceDirectoryString;
+
traceDirectoryString = readSystemProperty(Attribute.CLIENT_JVM_PROPERTY_PREFIX+Attribute.CLIENT_TRACE_DIRECTORY);
+
if (traceDirectoryString == null)
return properties.getProperty(Attribute.CLIENT_TRACE_DIRECTORY);
else
return traceDirectoryString;
}
+
/**
* Read the value of the passed system property.
* @param key name of the system property
- * @return value of the system property
+ * @return value of the system property, null if there is no permission to read the property
*/
private static String readSystemProperty(final String key) {
//Using an anonymous class to read the system privilege because the
@@ -404,7 +408,14 @@
return (String )AccessController.doPrivileged
(new java.security.PrivilegedAction(){
public Object run(){
- return System.getProperty(key);
+ try {
+ return System.getProperty(key);
+ } catch (SecurityException se) {
+ // We do not want the connection to fail if the user does not have permission to
+ // read the property, so if a security exception occurs, just return null and
+ // continue with the connection.
+ return null;
+ }
}
}
);