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 f1009c8ffab4efdead8c6f75c02d1245f0909186
Author: Martin Desruisseaux <[email protected]>
AuthorDate: Wed Aug 12 18:50:05 2020 +0200

    Fix a NullPointerException.
---
 .../src/main/java/org/apache/sis/internal/referencing/LazySet.java   | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git 
a/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/LazySet.java
 
b/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/LazySet.java
index a473300..d41cff3 100644
--- 
a/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/LazySet.java
+++ 
b/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/LazySet.java
@@ -207,12 +207,15 @@ public class LazySet<E> extends SetOfUnknownSize<E> {
     }
 
     /**
-     * Caches a new element. Subclasses can override this method is they want 
to substitute the given value
+     * Caches a new element. Subclasses can override this method if they want 
to substitute the given value
      * by another value.
      *
      * @param  element  the element to add to the cache.
      */
     protected void cache(final E element) {
+        if (cachedElements == null) {
+            createCache();
+        }
         if (numCached >= cachedElements.length) {
             cachedElements = Arrays.copyOf(cachedElements, numCached << 1);
         }

Reply via email to