sis-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From desruisse...@apache.org
Subject [sis] branch geoapi-4.0 updated: Remove support for JavaDB.
Date Mon, 09 Mar 2020 22:38:53 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


The following commit(s) were added to refs/heads/geoapi-4.0 by this push:
     new 3d1ad33  Remove support for JavaDB.
3d1ad33 is described below

commit 3d1ad33bb56e6d9c43cdb04fb81db8b5623f9edc
Author: Martin Desruisseaux <martin.desruisseaux@geomatys.com>
AuthorDate: Mon Mar 9 23:35:47 2020 +0100

    Remove support for JavaDB.
    
    JavaDB is not included in JDK 9 and has been removed from JDK 8 in update 181 (JDK 8u181).
    That update expired one year and half ago in October 16, 2018 (was released in July 17,
2018).
    
    https://issues.apache.org/jira/browse/SIS-492
---
 .../sis/internal/metadata/sql/LocalDataSource.java | 63 ++--------------------
 1 file changed, 5 insertions(+), 58 deletions(-)

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 81ac54c..f56d8fd 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
@@ -27,8 +27,6 @@ import java.lang.reflect.Method;
 import java.nio.file.Files;
 import java.nio.file.Path;
 import java.nio.file.Paths;
-import java.net.URL;
-import java.net.URLClassLoader;
 import java.util.logging.Level;
 import java.util.logging.Logger;
 import java.util.logging.LogRecord;
@@ -59,18 +57,6 @@ public final class LocalDataSource implements DataSource, Comparable<LocalDataSo
     private static final String DERBY_HOME_KEY = "derby.system.home";
 
     /**
-     * The class loader for JavaDB (i.e. the Derby database distributed with the JDK), created
when first needed.
-     * This field is never reset to {@code null} even if the classpath changed because this
class loader is for
-     * a JAR file the JDK installation directory, and we presume that the JDK installation
do not change.
-     *
-     * @see #initialize()
-     *
-     * @deprecated to be removed after we migrate to Java 9, since Derby is no longer distributed
with the JDK.
-     */
-    @Deprecated
-    private static URLClassLoader javadbLoader;
-
-    /**
      * The database product to use. Currently supported values are
      * {@link Dialect#DERBY} and {@link Dialect#HSQL}.
      */
@@ -94,8 +80,8 @@ public final class LocalDataSource implements DataSource, Comparable<LocalDataSo
     final boolean create;
 
     /**
-     * Prepares a new data source for the given database file. This construction is incomplete;
after return
-     * either {@link #initialize(ClassLoader)} shall be invoked or this {@code LocalDataSource}
is discarded.
+     * Prepares a new data source for the given database file. This construction is incomplete;
+     * after return either {@link #initialize()} shall be invoked or this {@code LocalDataSource}
is discarded.
      *
      * @param  dialect  {@link Dialect#DERBY} or {@link Dialect#HSQL}.
      * @param  dbFile   path to the database to open on the local file system.
@@ -201,22 +187,22 @@ public final class LocalDataSource implements DataSource, Comparable<LocalDataSo
     }
 
     /**
-     * Creates the data source using the given class loader.
+     * Creates the data source using the context class loader.
      * It is caller's responsibility to {@linkplain #shutdown() shutdown} the database after
usage.
      *
-     * @param  loader  the loader to use for loading the data source class.
      * @throws ClassNotFoundException if the database driver is not on the classpath.
      * @throws ReflectiveOperationException if an error occurred
      *         while setting the properties on the data source.
      */
     @SuppressWarnings("fallthrough")
-    private void initialize(final ClassLoader loader) throws ReflectiveOperationException
{
+    private void initialize() throws ReflectiveOperationException {
         final String classname;
         switch (dialect) {
             case DERBY: classname = "org.apache.derby.jdbc.EmbeddedDataSource"; break;
             case HSQL:  classname = "org.hsqldb.jdbc.JDBCDataSource"; break;
             default:    throw new IllegalArgumentException(dialect.toString());
         }
+        final ClassLoader loader = Thread.currentThread().getContextClassLoader();
         final Class<?> c = Class.forName(classname, true, loader);
         source = (DataSource) c.getConstructor().newInstance();
         final Class<?>[] args = {String.class};
@@ -228,45 +214,6 @@ public final class LocalDataSource implements DataSource, Comparable<LocalDataSo
     }
 
     /**
-     * Creates the data source using the context class loader if possible,
-     * or otherwise a URL class loader to the JavaDB distributed with the JDK.
-     *
-     * @throws ClassNotFoundException if the database driver is not on the classpath.
-     * @throws ReflectiveOperationException if an error occurred
-     *         while setting the properties on the data source.
-     * @throws java.net.MalformedURLException if the class loader for JavaDB can not be created.
-     */
-    private void initialize() throws Exception {
-        try {
-            initialize(Thread.currentThread().getContextClassLoader());
-        } catch (ClassNotFoundException e) {
-            if (dialect != Dialect.DERBY) {
-                throw e;
-            }
-            URLClassLoader loader;
-            synchronized (LocalDataSource.class) {
-                loader = javadbLoader;
-                if (loader == null) {
-                    final String home = System.getProperty("java.home");
-                    if (home != null) {
-                        final Path file = Paths.get(home).resolveSibling("db/lib/derby.jar");
-                        if (Files.isRegularFile(file)) {
-                            javadbLoader = loader = new URLClassLoader(new URL[] {
-                                file.toUri().toURL(),
-                                file.resolveSibling("derbynet.jar").toUri().toURL()
-                            });
-                        }
-                    }
-                }
-            }
-            if (loader == null) {
-                throw e;
-            }
-            initialize(loader);
-        }
-    }
-
-    /**
      * Returns the first data source from the given array that can be initialized.
      * The database may be located in the {@code $SIS_DATA/Databases/SpatialMetadata} directory,
      * or in the {@code SpatialMetadata} sub-directory of the path given by the {@code derby.system.home}
property.


Mime
View raw message