You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sis.apache.org by de...@apache.org on 2020/05/31 22:31:15 UTC
[sis] 01/02: Minor method renaming.
This is an automated email from the ASF dual-hosted git repository.
desruisseaux pushed a commit to branch geoapi-4.0
in repository https://gitbox.apache.org/repos/asf/sis.git
commit 5d82f2ab1e4605c392800775c1aa560031f930fb
Author: Martin Desruisseaux <ma...@geomatys.com>
AuthorDate: Sun May 31 00:17:06 2020 +0200
Minor method renaming.
---
.../org/apache/sis/internal/metadata/sql/Initializer.java | 13 ++++++++++---
.../apache/sis/internal/metadata/sql/LocalDataSource.java | 12 ++++++++++--
.../java/org/apache/sis/internal/system/DataDirectory.java | 6 +++---
3 files changed, 23 insertions(+), 8 deletions(-)
diff --git a/core/sis-metadata/src/main/java/org/apache/sis/internal/metadata/sql/Initializer.java b/core/sis-metadata/src/main/java/org/apache/sis/internal/metadata/sql/Initializer.java
index 0f8069a..d80a91e 100644
--- a/core/sis-metadata/src/main/java/org/apache/sis/internal/metadata/sql/Initializer.java
+++ b/core/sis-metadata/src/main/java/org/apache/sis/internal/metadata/sql/Initializer.java
@@ -321,7 +321,7 @@ public abstract class Initializer {
*/
DataSource embedded = null;
LocalDataSource[] candidates = null;
- final boolean isEnvClear = DataDirectory.isEnvClear();
+ final boolean isEnvClear = DataDirectory.isUndefined();
if (isEnvClear) {
embedded = embedded(); // Check embedded data first only if SIS_DATA is not defined.
}
@@ -369,8 +369,15 @@ public abstract class Initializer {
*/
public static boolean hasJNDI() {
return NamingManager.hasInitialContextFactoryBuilder() ||
- AccessController.doPrivileged((PrivilegedAction<Boolean>) () ->
- System.getProperty(Context.INITIAL_CONTEXT_FACTORY) != null);
+ AccessController.doPrivileged((PrivilegedAction<Boolean>) Initializer::isContextDefined);
+ }
+
+ /**
+ * Returns whether an initial context factory is specified.
+ * Defined as a separated method for clearer stack trace in case of security exception.
+ */
+ private static Boolean isContextDefined() {
+ return System.getProperty(Context.INITIAL_CONTEXT_FACTORY) != null;
}
/**
diff --git a/core/sis-metadata/src/main/java/org/apache/sis/internal/metadata/sql/LocalDataSource.java b/core/sis-metadata/src/main/java/org/apache/sis/internal/metadata/sql/LocalDataSource.java
index f56d8fd..c31f502 100644
--- a/core/sis-metadata/src/main/java/org/apache/sis/internal/metadata/sql/LocalDataSource.java
+++ b/core/sis-metadata/src/main/java/org/apache/sis/internal/metadata/sql/LocalDataSource.java
@@ -110,7 +110,7 @@ public final class LocalDataSource implements DataSource, Comparable<LocalDataSo
final String home;
switch (dialect) {
// More cases may be added in the future.
- case DERBY: home = AccessController.doPrivileged((PrivilegedAction<String>) () -> System.getProperty(DERBY_HOME_KEY)); break;
+ case DERBY: home = AccessController.doPrivileged((PrivilegedAction<String>) LocalDataSource::getDerbyHome); break;
default: home = null; break;
}
final String dbFile;
@@ -165,6 +165,14 @@ public final class LocalDataSource implements DataSource, Comparable<LocalDataSo
}
/**
+ * Returns the home directory of Derby databases, or {@code null} if none.
+ * Defined as a separated method for clearer stack trace in case of security exception.
+ */
+ private static String getDerbyHome() {
+ return System.getProperty(DERBY_HOME_KEY);
+ }
+
+ /**
* Wraps an existing data source for adding a shutdown method to it.
* This method is used for source of data embedded in a separated JAR file.
*
@@ -241,7 +249,7 @@ public final class LocalDataSource implements DataSource, Comparable<LocalDataSo
}
/**
- * Creates the database if needed. For Derby we need to explicitly allows creation.
+ * Creates the database if needed. For Derby we need to explicitly allow creation.
* For HSQLDB the creation is enabled by default.
*/
final void createDatabase() throws Exception {
diff --git a/core/sis-utility/src/main/java/org/apache/sis/internal/system/DataDirectory.java b/core/sis-utility/src/main/java/org/apache/sis/internal/system/DataDirectory.java
index 0dccacf..1ed2403 100644
--- a/core/sis-utility/src/main/java/org/apache/sis/internal/system/DataDirectory.java
+++ b/core/sis-utility/src/main/java/org/apache/sis/internal/system/DataDirectory.java
@@ -146,7 +146,7 @@ public enum DataDirectory {
}
/**
- * Returns {@code true} if the {@value #ENV} environment variable is unset. In case of doubt, this method
+ * Returns {@code true} if the {@value #ENV} environment variable is undefined. In case of doubt, this method
* returns {@code false}. This method is used for avoiding or at least delaying the log messages emitted by
* {@link #getRootDirectory()} when a fallback exists in absence of any user attempt to configure the system.
*
@@ -154,11 +154,11 @@ public enum DataDirectory {
*
* @since 0.8
*/
- public static synchronized boolean isEnvClear() {
+ public static synchronized boolean isUndefined() {
if (rootDirectory == null) try {
return getenv() == null;
} catch (SecurityException e) {
- Logging.recoverableException(Logging.getLogger(Loggers.SYSTEM), DataDirectory.class, "isEnvClear", e);
+ Logging.recoverableException(Logging.getLogger(Loggers.SYSTEM), DataDirectory.class, "isUndefined", e);
}
return false;
}