sis-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From desruisse...@apache.org
Subject [sis] 02/02: Fix a `NullPointerException` when `bin/sisfx` is invoked while `apache-sis-<version>` is the current directory.
Date Thu, 28 Jan 2021 00:38:04 GMT
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 2ca318cc4a950f08317305ee3e19d5b8db495473
Author: Martin Desruisseaux <martin.desruisseaux@geomatys.com>
AuthorDate: Thu Jan 28 01:35:31 2021 +0100

    Fix a `NullPointerException` when `bin/sisfx` is invoked while `apache-sis-<version>`
is the current directory.
---
 .../apache/sis/internal/setup/LoggingConfiguration.java    | 14 ++++++++------
 .../org/apache/sis/internal/storage/io/IOUtilities.java    |  5 +++++
 2 files changed, 13 insertions(+), 6 deletions(-)

diff --git a/application/sis-javafx/src/main/java/org/apache/sis/internal/setup/LoggingConfiguration.java
b/application/sis-javafx/src/main/java/org/apache/sis/internal/setup/LoggingConfiguration.java
index b03a302..6cf9b0d 100644
--- a/application/sis-javafx/src/main/java/org/apache/sis/internal/setup/LoggingConfiguration.java
+++ b/application/sis-javafx/src/main/java/org/apache/sis/internal/setup/LoggingConfiguration.java
@@ -24,17 +24,19 @@ import java.nio.file.Files;
 import java.nio.file.Path;
 import java.nio.file.Paths;
 
+import static org.apache.sis.internal.storage.io.IOUtilities.CURRENT_DIRECTORY_SYMBOL;
+
 
 /**
- * Loads {@code conf/logging.properties} file and filter the {@code %b} pattern
+ * Loads {@code conf/logging.properties} file and filter the {@code %p} pattern
  * before to delegate to Java logging system. The filtering replaces {@code "%p"}
  * by the parent directory of configuration file.
  *
- * <p>This class should not use any SIS classes because it may be invoked early
- * while the application is still initializing.</p>
+ * <p>This class should not use any SIS classes (except constants inlined at compile-time)
+ * because it may be invoked early while the application is still initializing.</p>
  *
- * <p>This class is not referenced directly by other Java code. Instead, it is
- * specified at JVM startup time like below:</p>
+ * <p>This class is not referenced directly by other Java code.
+ * Instead, it is specified at JVM startup time like below:</p>
  *
  * {@preformat shell
  *     java -Djava.util.logging.config.class="org.apache.sis.internal.setup.LoggingConfiguration"
@@ -79,7 +81,7 @@ public final class LoggingConfiguration {
                             for (int j=Math.min(parent.getNameCount(), 2); --j >= 0;)
{
                                 parent = parent.getParent();
                             }
-                            String replacement = parent.toString();
+                            String replacement = (parent != null) ? parent.toString() : CURRENT_DIRECTORY_SYMBOL;
                             replacement = replacement.replace(File.separatorChar, '/');
                             buffer.replace(i, i + PATTERN.length(), replacement);
                         }
diff --git a/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/io/IOUtilities.java
b/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/io/IOUtilities.java
index ea5f894..2c65096 100644
--- a/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/io/IOUtilities.java
+++ b/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/io/IOUtilities.java
@@ -65,6 +65,11 @@ import org.apache.sis.internal.storage.Resources;
  */
 public final class IOUtilities extends Static {
     /**
+     * The symbol for current directory.
+     */
+    public static final String CURRENT_DIRECTORY_SYMBOL = ".";
+
+    /**
      * Do not allow instantiation of this class.
      */
     private IOUtilities() {


Mime
View raw message