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: Add a check for null JNDI context.
Date Mon, 06 Jan 2020 13:57:22 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 edfff44  Add a check for null JNDI context.
edfff44 is described below

commit edfff448f6fb782b41c10c158ee951cc7b8a7fb4
Author: Martin Desruisseaux <martin.desruisseaux@geomatys.com>
AuthorDate: Mon Jan 6 14:57:02 2020 +0100

    Add a check for null JNDI context.
---
 .../sis/internal/metadata/sql/Initializer.java     | 22 ++++++++++++----------
 1 file changed, 12 insertions(+), 10 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 288c8a1..b191d7c 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
@@ -297,17 +297,19 @@ public abstract class Initializer {
         if (source == null) {
             if (hasJNDI()) try {
                 final Context env = (Context) InitialContext.doLookup("java:comp/env");
-                source = (DataSource) env.lookup(JNDI);
-                if (env instanceof EventContext) {
-                    Listener.register((EventContext) env);
+                if (env != null) {
+                    source = (DataSource) env.lookup(JNDI);
+                    if (env instanceof EventContext) {
+                        Listener.register((EventContext) env);
+                    }
+                    return source;
+                    /*
+                     * No Derby shutdown hook for DataSource fetched from JNDI.
+                     * We presume that shutdowns are handled by the container.
+                     * We do not clear the 'supplier' field in case 'source'
+                     * is cleaned by the listener.
+                     */
                 }
-                return source;
-                /*
-                 * No Derby shutdown hook for DataSource fetched fron JNDI.
-                 * We presume that shutdowns are handled by the container.
-                 * We do not clear the 'supplier' field in case 'source'
-                 * is cleaned by the listener.
-                 */
             } catch (NameNotFoundException e) {
                 final LogRecord record = Messages.getResources(null).getLogRecord(
                         Level.CONFIG, Messages.Keys.JNDINotSpecified_1, JNDI);


Mime
View raw message