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 rh...@apache.org on 2022/05/06 16:54:50 UTC
svn commit: r1900634 - in /db/derby/code/trunk/java: org.apache.derby.client/org/apache/derby/client/am/ org.apache.derby.engine/org/apache/derby/impl/services/monitor/ org.apache.derby.tests/org/apache/derbyTesting/functionTests/tests/store/
Author: rhillegas
Date: Fri May 6 16:54:50 2022
New Revision: 1900634
URL: http://svn.apache.org/viewvc?rev=1900634&view=rev
Log:
DERBY-7138: Remove more references to the SecurityManager; commit derby-7138-16-aa-removeMoreReferences.diff.
Modified:
db/derby/code/trunk/java/org.apache.derby.client/org/apache/derby/client/am/Version.java
db/derby/code/trunk/java/org.apache.derby.engine/org/apache/derby/impl/services/monitor/StorageFactoryService.java
db/derby/code/trunk/java/org.apache.derby.tests/org/apache/derbyTesting/functionTests/tests/store/Derby5582AutomaticIndexStatisticsTest.java
Modified: db/derby/code/trunk/java/org.apache.derby.client/org/apache/derby/client/am/Version.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/org.apache.derby.client/org/apache/derby/client/am/Version.java?rev=1900634&r1=1900633&r2=1900634&view=diff
==============================================================================
--- db/derby/code/trunk/java/org.apache.derby.client/org/apache/derby/client/am/Version.java (original)
+++ db/derby/code/trunk/java/org.apache.derby.client/org/apache/derby/client/am/Version.java Fri May 6 16:54:50 2022
@@ -59,8 +59,6 @@ public abstract class Version {
// -------------------------- configuration print stream ---------------------
- // SecurityManager deprecated for removal by JEP 411 https://openjdk.java.net/jeps/411
- @SuppressWarnings("removal")
static void writeDriverConfiguration(PrintWriter printWriter) {
String header = "[derby] ";
synchronized (printWriter) {
@@ -82,89 +80,64 @@ public abstract class Version {
printWriter.println(header + "Default fetch size: " + Configuration.defaultFetchSize);
printWriter.println(header + "Default isolation: " + Configuration.defaultIsolation);
- SecurityManager security = System.getSecurityManager();
- if (security == null) {
- printWriter.println(header + "No security manager detected.");
- } else {
- printWriter.println(header + "Security manager detected.");
- }
-
- detectLocalHost(System.getSecurityManager(), printWriter);
+ detectLocalHost(printWriter);
- printSystemProperty(security, "JDBC 1 system property jdbc.drivers = ", "jdbc.drivers", printWriter);
+ printSystemProperty("JDBC 1 system property jdbc.drivers = ", "jdbc.drivers", printWriter);
- printSystemProperty(security, "Java Runtime Environment version ", "java.version", printWriter);
- printSystemProperty(security, "Java Runtime Environment vendor = ", "java.vendor", printWriter);
- printSystemProperty(security, "Java vendor URL = ", "java.vendor.url", printWriter);
- printSystemProperty(security, "Java installation directory = ", "java.home", printWriter);
- printSystemProperty(security, "Java Virtual Machine specification version = ", "java.vm.specification.version", printWriter);
- printSystemProperty(security, "Java Virtual Machine specification vendor = ", "java.vm.specification.vendor", printWriter);
- printSystemProperty(security, "Java Virtual Machine specification name = ", "java.vm.specification.name", printWriter);
- printSystemProperty(security, "Java Virtual Machine implementation version = ", "java.vm.version", printWriter);
- printSystemProperty(security, "Java Virtual Machine implementation vendor = ", "java.vm.vendor", printWriter);
- printSystemProperty(security, "Java Virtual Machine implementation name = ", "java.vm.name", printWriter);
- printSystemProperty(security, "Java Runtime Environment specification version = ", "java.specification.version", printWriter);
- printSystemProperty(security, "Java Runtime Environment specification vendor = ", "java.specification.vendor", printWriter);
- printSystemProperty(security, "Java Runtime Environment specification name = ", "java.specification.name", printWriter);
- printSystemProperty(security, "Java class format version number = ", "java.class.version", printWriter);
- printSystemProperty(security, "Java class path = ", "java.class.path", printWriter);
- printSystemProperty(security, "Java native library path = ", "java.library.path", printWriter);
- printSystemProperty(security, "Path of extension directory or directories = ", "java.ext.dirs", printWriter);
- printSystemProperty(security, "Operating system name = ", "os.name", printWriter);
- printSystemProperty(security, "Operating system architecture = ", "os.arch", printWriter);
- printSystemProperty(security, "Operating system version = ", "os.version", printWriter);
- printSystemProperty(security, "File separator (\"/\" on UNIX) = ", "file.separator", printWriter);
- printSystemProperty(security, "Path separator (\":\" on UNIX) = ", "path.separator", printWriter);
- printSystemProperty(security, "User's account name = ", "user.name", printWriter);
- printSystemProperty(security, "User's home directory = ", "user.home", printWriter);
- printSystemProperty(security, "User's current working directory = ", "user.dir", printWriter);
+ printSystemProperty( "Java Runtime Environment version ", "java.version", printWriter);
+ printSystemProperty( "Java Runtime Environment vendor = ", "java.vendor", printWriter);
+ printSystemProperty( "Java vendor URL = ", "java.vendor.url", printWriter);
+ printSystemProperty( "Java installation directory = ", "java.home", printWriter);
+ printSystemProperty( "Java Virtual Machine specification version = ", "java.vm.specification.version", printWriter);
+ printSystemProperty( "Java Virtual Machine specification vendor = ", "java.vm.specification.vendor", printWriter);
+ printSystemProperty( "Java Virtual Machine specification name = ", "java.vm.specification.name", printWriter);
+ printSystemProperty( "Java Virtual Machine implementation version = ", "java.vm.version", printWriter);
+ printSystemProperty( "Java Virtual Machine implementation vendor = ", "java.vm.vendor", printWriter);
+ printSystemProperty( "Java Virtual Machine implementation name = ", "java.vm.name", printWriter);
+ printSystemProperty( "Java Runtime Environment specification version = ", "java.specification.version", printWriter);
+ printSystemProperty( "Java Runtime Environment specification vendor = ", "java.specification.vendor", printWriter);
+ printSystemProperty( "Java Runtime Environment specification name = ", "java.specification.name", printWriter);
+ printSystemProperty( "Java class format version number = ", "java.class.version", printWriter);
+ printSystemProperty( "Java class path = ", "java.class.path", printWriter);
+ printSystemProperty( "Java native library path = ", "java.library.path", printWriter);
+ printSystemProperty( "Path of extension directory or directories = ", "java.ext.dirs", printWriter);
+ printSystemProperty( "Operating system name = ", "os.name", printWriter);
+ printSystemProperty( "Operating system architecture = ", "os.arch", printWriter);
+ printSystemProperty( "Operating system version = ", "os.version", printWriter);
+ printSystemProperty( "File separator (\"/\" on UNIX) = ", "file.separator", printWriter);
+ printSystemProperty( "Path separator (\":\" on UNIX) = ", "path.separator", printWriter);
+ printSystemProperty( "User's account name = ", "user.name", printWriter);
+ printSystemProperty( "User's home directory = ", "user.home", printWriter);
+ printSystemProperty( "User's current working directory = ", "user.dir", printWriter);
printWriter.println(header + "END TRACE_DRIVER_CONFIGURATION");
printWriter.flush();
}
}
- // SecurityManager deprecated for removal by JEP 411 https://openjdk.java.net/jeps/411
- @SuppressWarnings("removal")
- private static void printSystemProperty(SecurityManager security,
- String prefix,
+ private static void printSystemProperty(String prefix,
String property,
PrintWriter printWriter) {
String header = "[derby] ";
synchronized (printWriter) {
- try {
- if (security != null) {
- security.checkPropertyAccess(property);
- }
- String result = System.getProperty(property);
- printWriter.println(header + prefix + result);
- printWriter.flush();
- } catch (SecurityException e) {
- printWriter.println(header +
- msgutil.getTextMessage(MessageId.SECURITY_MANAGER_NO_ACCESS_ID, property));
- printWriter.flush();
- }
+ String result = System.getProperty(property);
+ printWriter.println(header + prefix + result);
+ printWriter.flush();
}
}
// printWriter synchronized by caller
- // SecurityManager deprecated for removal by JEP 411 https://openjdk.java.net/jeps/411
- @SuppressWarnings("removal")
private static void detectLocalHost(
- SecurityManager security,
PrintWriter printWriter) {
String header = "[derby] ";
- // getLocalHost() will hang the HotJava 1.0 browser with a high security manager.
- if (security == null) {
- try {
- printWriter.print(header + "Detected local client host: ");
- printWriter.println(InetAddress.getLocalHost().toString());
- printWriter.flush();
- } catch (UnknownHostException e) {
- printWriter.println(header +
- msgutil.getTextMessage(MessageId.UNKNOWN_HOST_ID, e.getMessage()));
- printWriter.flush();
- }
+ try {
+ printWriter.print(header + "Detected local client host: ");
+ printWriter.println(InetAddress.getLocalHost().toString());
+ printWriter.flush();
+ } catch (UnknownHostException e) {
+ printWriter.println(header +
+ msgutil.getTextMessage(MessageId.UNKNOWN_HOST_ID, e.getMessage()));
+ printWriter.flush();
}
}
}
Modified: db/derby/code/trunk/java/org.apache.derby.engine/org/apache/derby/impl/services/monitor/StorageFactoryService.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/org.apache.derby.engine/org/apache/derby/impl/services/monitor/StorageFactoryService.java?rev=1900634&r1=1900633&r2=1900634&view=diff
==============================================================================
--- db/derby/code/trunk/java/org.apache.derby.engine/org/apache/derby/impl/services/monitor/StorageFactoryService.java (original)
+++ db/derby/code/trunk/java/org.apache.derby.engine/org/apache/derby/impl/services/monitor/StorageFactoryService.java Fri May 6 16:54:50 2022
@@ -1089,26 +1089,13 @@ final class StorageFactoryService implem
return deleted;
}
- // SecurityManager deprecated for removal by JEP 411 https://openjdk.java.net/jeps/411
- @SuppressWarnings("removal")
boolean renameTo(StorageFile from, StorageFile to, boolean mustSucceed)
throws StandardException {
operation = "renameTo";
// Even if the explicit delete fails, the rename may succeed.
delete(to, false);
boolean renamed = false;
- try {
- renamed = from.renameTo(to);
- } catch (SecurityException se) {
- StorageFile file = to;
- try {
- // We got a security exception, assume a secman is present.
- System.getSecurityManager().checkWrite(from.getPath());
- } catch (SecurityException se1) {
- file = from;
- }
- handleSecPrivException(file, mustSucceed, se);
- }
+ renamed = from.renameTo(to);
if (mustSucceed && !renamed) {
throw StandardException.newException(
SQLState.UNABLE_TO_RENAME_FILE,
Modified: db/derby/code/trunk/java/org.apache.derby.tests/org/apache/derbyTesting/functionTests/tests/store/Derby5582AutomaticIndexStatisticsTest.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/org.apache.derby.tests/org/apache/derbyTesting/functionTests/tests/store/Derby5582AutomaticIndexStatisticsTest.java?rev=1900634&r1=1900633&r2=1900634&view=diff
==============================================================================
--- db/derby/code/trunk/java/org.apache.derby.tests/org/apache/derbyTesting/functionTests/tests/store/Derby5582AutomaticIndexStatisticsTest.java (original)
+++ db/derby/code/trunk/java/org.apache.derby.tests/org/apache/derbyTesting/functionTests/tests/store/Derby5582AutomaticIndexStatisticsTest.java Fri May 6 16:54:50 2022
@@ -26,8 +26,6 @@ import org.apache.derbyTesting.junit.Tes
public class Derby5582AutomaticIndexStatisticsTest extends AutomaticIndexStatisticsTest {
- // private thread group. Derby5582SecurityManager will prevent other threads from
- // modifying this thread group.
private static final String PRIVTGNAME = "privtg";
public Derby5582AutomaticIndexStatisticsTest(String name) {
@@ -38,7 +36,7 @@ public class Derby5582AutomaticIndexStat
/**
* DERBY-5582 Ensure automatic statistics update thread can be created in the
* context of a SecurityManager that disallows modification of the parent
- * thread thread group.
+ * thread thread group. NOP now.
*
* @throws InterruptedException
*/
@@ -63,32 +61,11 @@ public class Derby5582AutomaticIndexStat
public static Test suite() {
- // Run just the one fixture with the custom SecurityManager
Test t = new Derby5582AutomaticIndexStatisticsTest("testDerby5582");
- Derby5582SecurityManager sm = new Derby5582SecurityManager();
return TestConfiguration.additionalDatabaseDecorator(t, MASTERDB);
}
/**
- * SecurityManager which prevents modification of thread group privtg
- *
- */
- // SecurityManager deprecated for removal by JEP 411 https://openjdk.java.net/jeps/411
- @SuppressWarnings("removal")
- public static class Derby5582SecurityManager extends SecurityManager {
-
- public void checkAccess(ThreadGroup tg) {
- ThreadGroup currentGroup = Thread.currentThread().getThreadGroup();
- if (tg.getName().equals(PRIVTGNAME) &&
- !currentGroup.getName().equals("main")) {
- throw new SecurityException("No permission to private ThreadGroup privtg");
-
- }
- super.checkAccess(tg);
- }
- }
-
- /**
* Runnable to run testSTatsUpdatedOnGrowthFixture from
* AutomaticStatisticsTest. Needs to be run in a separate thread
* with disallowed ThreadGroup modification