sis-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From desruisse...@apache.org
Subject svn commit: r1792361 - in /sis/branches/JDK8: core/sis-metadata/src/main/java/org/apache/sis/metadata/sql/ core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/sql/ storage/sis-xmlstore/src/main/java/org/apache/sis/internal/storage/gpx/
Date Sun, 23 Apr 2017 13:31:07 GMT
Author: desruisseaux
Date: Sun Apr 23 13:31:07 2017
New Revision: 1792361

URL: http://svn.apache.org/viewvc?rev=1792361&view=rev
Log:
Minor simplification of the stack trace in case of failure to connect to the database.

Modified:
    sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/metadata/sql/MetadataSource.java
    sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/sql/EPSGFactory.java
    sis/branches/JDK8/storage/sis-xmlstore/src/main/java/org/apache/sis/internal/storage/gpx/Types.java

Modified: sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/metadata/sql/MetadataSource.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/metadata/sql/MetadataSource.java?rev=1792361&r1=1792360&r2=1792361&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/metadata/sql/MetadataSource.java
[UTF-8] (original)
+++ sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/metadata/sql/MetadataSource.java
[UTF-8] Sun Apr 23 13:31:07 2017
@@ -41,7 +41,6 @@ import java.sql.Statement;
 import java.sql.ResultSet;
 import java.sql.SQLException;
 import java.sql.SQLNonTransientException;
-import java.io.IOException;
 import java.sql.PreparedStatement;
 import org.opengis.annotation.UML;
 import org.opengis.util.CodeList;
@@ -391,8 +390,16 @@ public class MetadataSource implements A
             }
             final Installer installer = new Installer(connection);
             installer.run();
-        } catch (IOException | SQLException e) {
-            throw new MetadataStoreException(e);
+        } catch (Exception e) {
+            /*
+             * 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.
+             */
+            final String message = e.getLocalizedMessage();
+            for (Throwable cause; e.getClass().isInstance(cause = e.getCause());) {
+                e = (Exception) cause;
+            }
+            throw new MetadataStoreException(message, e);
         }
     }
 

Modified: sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/sql/EPSGFactory.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/sql/EPSGFactory.java?rev=1792361&r1=1792360&r2=1792361&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/sql/EPSGFactory.java
[UTF-8] (original)
+++ sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/sql/EPSGFactory.java
[UTF-8] Sun Apr 23 13:31:07 2017
@@ -459,7 +459,15 @@ public class EPSGFactory extends Concurr
             } catch (SQLException e2) {
                 e.addSuppressed(e2);
             }
-            exception = new UnavailableFactoryException(message(e), e);
+            /*
+             * 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.
+             */
+            final String message = message(e);
+            for (Throwable cause; e.getClass().isInstance(cause = e.getCause());) {
+                e = (Exception) cause;
+            }
+            exception = new UnavailableFactoryException(message, e);
         }
         exception.setUnavailableFactory(this);
         throw exception;

Modified: sis/branches/JDK8/storage/sis-xmlstore/src/main/java/org/apache/sis/internal/storage/gpx/Types.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/storage/sis-xmlstore/src/main/java/org/apache/sis/internal/storage/gpx/Types.java?rev=1792361&r1=1792360&r2=1792361&view=diff
==============================================================================
--- sis/branches/JDK8/storage/sis-xmlstore/src/main/java/org/apache/sis/internal/storage/gpx/Types.java
[UTF-8] (original)
+++ sis/branches/JDK8/storage/sis-xmlstore/src/main/java/org/apache/sis/internal/storage/gpx/Types.java
[UTF-8] Sun Apr 23 13:31:07 2017
@@ -41,12 +41,12 @@ import org.apache.sis.feature.builder.At
 import org.apache.sis.internal.feature.AttributeConvention;
 import org.apache.sis.internal.storage.FeatureCatalogBuilder;
 import org.apache.sis.internal.system.DefaultFactories;
+import org.apache.sis.util.iso.ResourceInternationalString;
 import org.apache.sis.util.iso.DefaultNameFactory;
 import org.apache.sis.util.Static;
 
 // Branch-dependent imports
 import java.time.temporal.Temporal;
-import org.apache.sis.util.iso.ResourceInternationalString;
 import org.opengis.feature.FeatureType;
 
 



Mime
View raw message