sis-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From desruisse...@apache.org
Subject [sis] 01/02: Use Level.CONFIG instead of Level.WARNING if Derby driver is not on the classpath since Derby is optional.
Date Sat, 10 Nov 2018 16:19:56 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 7655964b6ee9611910ba61d00ea6a67342e937b6
Author: Martin Desruisseaux <martin.desruisseaux@geomatys.com>
AuthorDate: Sat Nov 10 15:14:20 2018 +0100

    Use Level.CONFIG instead of Level.WARNING if Derby driver is not on the classpath since
Derby is optional.
---
 .../java/org/apache/sis/internal/metadata/ServicesForUtility.java     | 2 +-
 .../main/java/org/apache/sis/internal/metadata/sql/Initializer.java   | 2 +-
 .../src/main/java/org/apache/sis/metadata/sql/MetadataSource.java     | 4 ++++
 storage/pom.xml                                                       | 1 +
 4 files changed, 7 insertions(+), 2 deletions(-)

diff --git a/core/sis-metadata/src/main/java/org/apache/sis/internal/metadata/ServicesForUtility.java
b/core/sis-metadata/src/main/java/org/apache/sis/internal/metadata/ServicesForUtility.java
index 60ed74b..21d6a1b 100644
--- a/core/sis-metadata/src/main/java/org/apache/sis/internal/metadata/ServicesForUtility.java
+++ b/core/sis-metadata/src/main/java/org/apache/sis/internal/metadata/ServicesForUtility.java
@@ -96,7 +96,7 @@ public final class ServicesForUtility extends MetadataServices {
                     Logging.recoverableException(Logging.getLogger(Loggers.SYSTEM),
                             MetadataServices.class, "getInformation", e);
                 } catch (Exception e) {
-                    // Leave the message alone if it contains at least 2 words.
+                    // Leave the message unchanged if it contains at least 2 words.
                     String message = Exceptions.getLocalizedMessage(e, locale);
                     if (message == null || message.indexOf(' ') < 0) {
                         message = Classes.getShortClassName(e) + ": " + message;
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 625bbf3..7a74797 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
@@ -504,7 +504,7 @@ public abstract class Initializer {
      * @return the data source.
      * @throws Exception if the data source can not be created.
      */
-    static DataSource forJavaDB(final String path) throws Exception {
+    private static DataSource forJavaDB(final String path) throws Exception {
         try {
             return forJavaDB(path, Thread.currentThread().getContextClassLoader());
         } catch (ClassNotFoundException e) {
diff --git a/core/sis-metadata/src/main/java/org/apache/sis/metadata/sql/MetadataSource.java
b/core/sis-metadata/src/main/java/org/apache/sis/metadata/sql/MetadataSource.java
index 86768eb..bfa009e 100644
--- a/core/sis-metadata/src/main/java/org/apache/sis/metadata/sql/MetadataSource.java
+++ b/core/sis-metadata/src/main/java/org/apache/sis/metadata/sql/MetadataSource.java
@@ -322,9 +322,13 @@ public class MetadataSource implements AutoCloseable {
                 /*
                  * Derby sometime wraps SQLException into another SQLException.  For making
the stack strace a
                  * little bit simpler, keep only the root cause provided that the exception
type is compatible.
+                 * If the Derby driver was not found at all, reduce the logging level since
Derby is optional.
                  */
                 warning = Errors.getResources((Locale) null).getLogRecord(Level.WARNING,
Errors.Keys.CanNotConnectTo_1, Initializer.JNDI);
                 warning.setThrown(Exceptions.unwrap(e));
+                if (e instanceof ClassNotFoundException) {
+                    warning.setLevel(Level.CONFIG);                         // Derby driver
not on the classpath.
+                }
                 /*
                  * If the error is transient or has a transient cause, we will not save MetadataFallback.INSTANCE
                  * in the 'instance' field. The intent is to try again next time this method
will be invoked, in
diff --git a/storage/pom.xml b/storage/pom.xml
index 6a6d505..4391183 100644
--- a/storage/pom.xml
+++ b/storage/pom.xml
@@ -147,6 +147,7 @@
     <dependency>
       <groupId>org.apache.derby</groupId>
       <artifactId>derby</artifactId>
+      <scope>test</scope>
     </dependency>
     <dependency>
       <groupId>org.apache.sis.core</groupId>


Mime
View raw message