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: Fix a ClassCastException when processing a list of Referencing objects in metadata.
Date Fri, 17 Aug 2018 14:06:16 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 8a49bc2  Fix a ClassCastException when processing a list of Referencing objects in
metadata.
8a49bc2 is described below

commit 8a49bc264601719c9881d41a37a957be7428111d
Author: Martin Desruisseaux <martin.desruisseaux@geomatys.com>
AuthorDate: Fri Aug 17 16:05:47 2018 +0200

    Fix a ClassCastException when processing a list of Referencing objects in metadata.
---
 .../src/main/java/org/apache/sis/metadata/CacheKey.java      |  9 +++++----
 .../src/main/java/org/apache/sis/metadata/Pruner.java        | 12 ++++++------
 2 files changed, 11 insertions(+), 10 deletions(-)

diff --git a/core/sis-metadata/src/main/java/org/apache/sis/metadata/CacheKey.java b/core/sis-metadata/src/main/java/org/apache/sis/metadata/CacheKey.java
index 2d722cf..7dcc836 100644
--- a/core/sis-metadata/src/main/java/org/apache/sis/metadata/CacheKey.java
+++ b/core/sis-metadata/src/main/java/org/apache/sis/metadata/CacheKey.java
@@ -30,14 +30,15 @@ import org.apache.sis.util.resources.Errors;
  */
 final class CacheKey {
     /**
-     * The metadata class (interface or implementation) for which an {@link PropertyAccessor}
will be associated.
+     * The metadata class (interface or implementation) for which a {@link PropertyAccessor}
will be associated.
+     * May be null if unknown, in which case {@link #isValid()} returns {@code false}.
      */
     final Class<?> type;
 
     /**
-     * If the {@link #type} is the return value of a property, then the type of that property.
-     * This information allows to handle classes that implement more than one metadata interfaces
-     * for convenience, as for example in the {@link org.apache.sis.internal.simple} package.
+     * If the {@link #type} is an implementation class of a property, then the type declared
in the signature for
+     * that property. This information allows to handle classes that implement more than
one metadata interfaces
+     * for their convenience. Some examples are found in the {@link org.apache.sis.internal.simple}
package.
      *
      * <p>This field shall never be null. If there is no property type information,
      * then this field shall be set to {@code Object.class}.</p>
diff --git a/core/sis-metadata/src/main/java/org/apache/sis/metadata/Pruner.java b/core/sis-metadata/src/main/java/org/apache/sis/metadata/Pruner.java
index b2fbc85..4c14e62 100644
--- a/core/sis-metadata/src/main/java/org/apache/sis/metadata/Pruner.java
+++ b/core/sis-metadata/src/main/java/org/apache/sis/metadata/Pruner.java
@@ -121,7 +121,7 @@ final class Pruner extends MetadataVisitor<Boolean> {
             if (!isNullOrEmpty(element)) {
                 /*
                  * At this point, 'element' is not an empty CharSequence, Collection or array.
-                 * It may be an other metadata, a Java primitive type or user-defined object.
+                 * It may be another metadata, a Java primitive type or user-defined object.
                  *
                  *  - For AbstractMetadata, delegate to the public API in case it has been
overriden.
                  *  - For user-defined Emptiable, delegate to the user's isEmpty() method.
Note that
@@ -142,18 +142,18 @@ final class Pruner extends MetadataVisitor<Boolean> {
                          * For implementation that are not subtype of AbstractMetadata but
nevertheless
                          * implement some metadata interfaces, we will invoke recursively
this method.
                          */
-                        final Boolean r = walk(standard, type, value, false);
+                        final Boolean r = walk(standard, type, element, false);
                         if (r != null) {
                             isEmptyElement = r;
                             if (!isEmptyElement && element instanceof Emptiable)
{
                                 isEmptyElement = ((Emptiable) element).isEmpty();
                             }
                         }
-                    } else if (value instanceof Number) {
-                        isEmptyElement = Double.isNaN(((Number) value).doubleValue());
-                    } else if (value instanceof Boolean) {
+                    } else if (element instanceof Number) {
+                        isEmptyElement = Double.isNaN(((Number) element).doubleValue());
+                    } else if (element instanceof Boolean) {
                         // Typically methods of the kind 'isFooAvailable()'.
-                        isEmptyElement = !((Boolean) value);
+                        isEmptyElement = !((Boolean) element);
                     }
                 }
                 if (!isEmptyElement) {


Mime
View raw message