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: Avoid a NullPointerException which may happen with non-standard logging configuration. The null logging Level has been observed when using HSQL.
Date Wed, 28 Aug 2019 09:31:31 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 4d20d15  Avoid a NullPointerException which may happen with non-standard logging
configuration. The null logging Level has been observed when using HSQL.
4d20d15 is described below

commit 4d20d15147908f733b169441822319f915bfe4ac
Author: Martin Desruisseaux <martin.desruisseaux@geomatys.com>
AuthorDate: Wed Aug 28 11:30:10 2019 +0200

    Avoid a NullPointerException which may happen with non-standard logging configuration.
    The null logging Level has been observed when using HSQL.
---
 .../src/main/java/org/apache/sis/setup/About.java   | 21 +++++++++++++--------
 1 file changed, 13 insertions(+), 8 deletions(-)

diff --git a/core/sis-utility/src/main/java/org/apache/sis/setup/About.java b/core/sis-utility/src/main/java/org/apache/sis/setup/About.java
index b80340f..4ec110c 100644
--- a/core/sis-utility/src/main/java/org/apache/sis/setup/About.java
+++ b/core/sis-utility/src/main/java/org/apache/sis/setup/About.java
@@ -349,14 +349,19 @@ fill:   for (int i=0; ; i++) {
                     if (sections.contains(LOGGING)) {
                         nameKey = Vocabulary.Keys.Level;
                         final Level level = Logging.getLogger("").getLevel();   // Root logger
level.
-                        value = level.getLocalizedName();
-                        final Map<String,Level> levels = Loggers.getEffectiveLevels();
-                        if (levels.size() != 1 || !level.equals(levels.get(Loggers.ROOT)))
{
-                            int j = 0;
-                            children = new String[levels.size() * 2];
-                            for (final Map.Entry<String,Level> entry : levels.entrySet())
{
-                                children[j++] = entry.getKey();
-                                children[j++] = entry.getValue().getLocalizedName();
+                        if (level == null) {
+                            // May happen when some code outside Apache SIS define their
own loggers.
+                            value = resources.getString(Vocabulary.Keys.Unknown);
+                        } else {
+                            value = level.getLocalizedName();
+                            final Map<String,Level> levels = Loggers.getEffectiveLevels();
+                            if (levels.size() != 1 || !level.equals(levels.get(Loggers.ROOT)))
{
+                                int j = 0;
+                                children = new String[levels.size() * 2];
+                                for (final Map.Entry<String,Level> entry : levels.entrySet())
{
+                                    children[j++] = entry.getKey();
+                                    children[j++] = entry.getValue().getLocalizedName();
+                                }
                             }
                         }
                     }


Mime
View raw message