You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sis.apache.org by de...@apache.org on 2025/12/19 18:06:24 UTC

(sis) branch geoapi-4.0 updated (50721b3016 -> 89be530257)

This is an automated email from the ASF dual-hosted git repository.

desruisseaux pushed a change to branch geoapi-4.0
in repository https://gitbox.apache.org/repos/asf/sis.git


    from 50721b3016 Upgrade UCAR dependency.
     new 4bc9a2c93f Avoid spurious errors with XML configuration. This commit does not resolve the problems, it only hides them for now.
     new 89be530257 Add a `CheckedContainer.getMutability()` method.

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 .../sis/feature/internal/shared/InstantList.java   | 10 +++
 .../main/org/apache/sis/index/tree/PointTree.java  | 12 +++-
 .../apache/sis/metadata/PropertyInformation.java   | 16 +++--
 .../iso/quality/DefaultEvaluationMethod.java       | 14 +++-
 .../sis/xml/internal/shared/InputFactory.java      | 22 ++++--
 .../sis/xml/internal/shared/InputFactoryTest.java  |  3 +
 .../org/apache/sis/parameter/MatrixParameters.java | 13 +++-
 .../org/apache/sis/parameter/package-info.java     |  2 +-
 .../referencing/factory/IdentifiedObjectSet.java   | 13 +++-
 .../sis/referencing/factory/package-info.java      |  2 +-
 .../org/apache/sis/io/stream/UpdatableWrite.java   | 12 +++-
 .../main/org/apache/sis/math/ArrayVector.java      | 10 +++
 .../main/org/apache/sis/math/package-info.java     |  2 +-
 .../main/org/apache/sis/measure/Range.java         | 13 +++-
 .../main/org/apache/sis/measure/package-info.java  |  2 +-
 .../sis/util/collection/CheckedContainer.java      | 84 +++++++++++++++++++++-
 .../apache/sis/util/collection/CodeListSet.java    | 13 +++-
 .../org/apache/sis/util/collection/DerivedSet.java | 11 +++
 .../org/apache/sis/util/collection/RangeSet.java   | 13 +++-
 .../apache/sis/util/collection/TableColumn.java    | 13 ++++
 .../apache/sis/util/collection/TreeNodeList.java   | 10 +++
 .../apache/sis/util/collection/WeakHashSet.java    | 11 +++
 .../sis/util/internal/shared/CheckedArrayList.java | 10 +++
 .../sis/util/internal/shared/CheckedHashSet.java   | 10 +++
 .../internal/shared/UnmodifiableArrayList.java     | 12 +++-
 .../test/org/apache/sis/setup/OptionKeyTest.java   |  4 ++
 26 files changed, 311 insertions(+), 26 deletions(-)


(sis) 02/02: Add a `CheckedContainer.getMutability()` method.

Posted by de...@apache.org.
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 89be530257a55136deab6ff5e013e35620217672
Author: Martin Desruisseaux <ma...@geomatys.com>
AuthorDate: Fri Dec 19 18:38:54 2025 +0100

    Add a `CheckedContainer.getMutability()` method.
---
 .../sis/feature/internal/shared/InstantList.java   | 10 +++
 .../main/org/apache/sis/index/tree/PointTree.java  | 12 +++-
 .../apache/sis/metadata/PropertyInformation.java   | 16 +++--
 .../iso/quality/DefaultEvaluationMethod.java       | 14 +++-
 .../org/apache/sis/parameter/MatrixParameters.java | 13 +++-
 .../org/apache/sis/parameter/package-info.java     |  2 +-
 .../referencing/factory/IdentifiedObjectSet.java   | 13 +++-
 .../sis/referencing/factory/package-info.java      |  2 +-
 .../org/apache/sis/io/stream/UpdatableWrite.java   | 12 +++-
 .../main/org/apache/sis/math/ArrayVector.java      | 10 +++
 .../main/org/apache/sis/math/package-info.java     |  2 +-
 .../main/org/apache/sis/measure/Range.java         | 13 +++-
 .../main/org/apache/sis/measure/package-info.java  |  2 +-
 .../sis/util/collection/CheckedContainer.java      | 84 +++++++++++++++++++++-
 .../apache/sis/util/collection/CodeListSet.java    | 13 +++-
 .../org/apache/sis/util/collection/DerivedSet.java | 11 +++
 .../org/apache/sis/util/collection/RangeSet.java   | 13 +++-
 .../apache/sis/util/collection/TableColumn.java    | 13 ++++
 .../apache/sis/util/collection/TreeNodeList.java   | 10 +++
 .../apache/sis/util/collection/WeakHashSet.java    | 11 +++
 .../sis/util/internal/shared/CheckedArrayList.java | 10 +++
 .../sis/util/internal/shared/CheckedHashSet.java   | 10 +++
 .../internal/shared/UnmodifiableArrayList.java     | 12 +++-
 .../test/org/apache/sis/setup/OptionKeyTest.java   |  4 ++
 24 files changed, 291 insertions(+), 21 deletions(-)

diff --git a/endorsed/src/org.apache.sis.feature/main/org/apache/sis/feature/internal/shared/InstantList.java b/endorsed/src/org.apache.sis.feature/main/org/apache/sis/feature/internal/shared/InstantList.java
index bd8b5cab43..7e6f10b85f 100644
--- a/endorsed/src/org.apache.sis.feature/main/org/apache/sis/feature/internal/shared/InstantList.java
+++ b/endorsed/src/org.apache.sis.feature/main/org/apache/sis/feature/internal/shared/InstantList.java
@@ -57,6 +57,16 @@ final class InstantList extends AbstractList<Instant> implements CheckedContaine
         return Instant.class;
     }
 
+    /**
+     * Indicates that this vector is immutable.
+     *
+     * @return {@link Mutability#IMMUTABLE}.
+     */
+    @Override
+    public final Mutability getMutability() {
+        return Mutability.IMMUTABLE;
+    }
+
     /**
      * Returns the number of instants in this list.
      *
diff --git a/endorsed/src/org.apache.sis.feature/main/org/apache/sis/index/tree/PointTree.java b/endorsed/src/org.apache.sis.feature/main/org/apache/sis/index/tree/PointTree.java
index eab845c693..23b4e3be44 100644
--- a/endorsed/src/org.apache.sis.feature/main/org/apache/sis/index/tree/PointTree.java
+++ b/endorsed/src/org.apache.sis.feature/main/org/apache/sis/index/tree/PointTree.java
@@ -73,7 +73,7 @@ import org.apache.sis.util.collection.CheckedContainer;
  *
  * @author  Chris Mattmann
  * @author  Martin Desruisseaux (Geomatys)
- * @version 1.4
+ * @version 1.6
  *
  * @param  <E>  the type of elements stored in this tree.
  *
@@ -275,6 +275,16 @@ public class PointTree<E> extends AbstractSet<E> implements CheckedContainer<E>
         return elementType;
     }
 
+    /**
+     * Indicates that this collection is modifiable (at least by default).
+     *
+     * @return {@link Mutability#MODIFIABLE} by default.
+     * @since 1.6
+     */
+    @Override
+    public Mutability getMutability() {
+        return Mutability.MODIFIABLE;
+    }
 
     /**
      * Removes all elements from this tree.
diff --git a/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/PropertyInformation.java b/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/PropertyInformation.java
index f25dfcbfcb..48773e075e 100644
--- a/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/PropertyInformation.java
+++ b/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/PropertyInformation.java
@@ -56,15 +56,12 @@ import org.opengis.metadata.citation.Responsibility;
  * This final class is immutable and thus thread-safe.
  *
  * @author  Martin Desruisseaux (Geomatys)
- * @version 1.4
  *
  * @param <E>  the value type, either the method return type if not a collection,
  *             or the type of elements in the collection otherwise.
  *
  * @see InformationMap
  * @see MetadataStandard#asInformationMap(Class, KeyNamePolicy)
- *
- * @since 0.3
  */
 final class PropertyInformation<E> extends SimpleIdentifier           // Implementing Identifier is part of SIS public API.
         implements ExtendedElementInformation, CheckedContainer<E>
@@ -129,7 +126,7 @@ final class PropertyInformation<E> extends SimpleIdentifier           // Impleme
      * @param  range        the range of valid values, or {@code null} if none. This information is associated to the
      *                      implementation method rather than the interface one, because it is specific to SIS.
      */
-    @SuppressWarnings({"unchecked","rawtypes"})
+    @SuppressWarnings({"unchecked","rawtypes","LocalVariableHidesMemberVariable"})
     PropertyInformation(final Citation standard, final String property, final Method getter,
                         final Class<E> elementType, final ValueRange range)
     {
@@ -239,6 +236,16 @@ final class PropertyInformation<E> extends SimpleIdentifier           // Impleme
         return elementType;
     }
 
+    /**
+     * Indicates that this vector is immutable.
+     *
+     * @return {@link Mutability#IMMUTABLE}.
+     */
+    @Override
+    public final Mutability getMutability() {
+        return Mutability.IMMUTABLE;
+    }
+
     /**
      * Returns the maximum number of times that values are required.
      * This method returns 0 if the property is forbidden, {@link Integer#MAX_VALUE}
@@ -355,6 +362,7 @@ final class PropertyInformation<E> extends SimpleIdentifier           // Impleme
         } else {
             buffer.append('∞');
         }
+        @SuppressWarnings("LocalVariableHidesMemberVariable")
         final InternationalString domainValue = getDomainValue();
         if (domainValue != null) {
             buffer.append(", domain=").append(domainValue);
diff --git a/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/iso/quality/DefaultEvaluationMethod.java b/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/iso/quality/DefaultEvaluationMethod.java
index 9e444e196b..82afa9270a 100644
--- a/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/iso/quality/DefaultEvaluationMethod.java
+++ b/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/iso/quality/DefaultEvaluationMethod.java
@@ -140,6 +140,14 @@ public class DefaultEvaluationMethod extends ISOMetadata implements EvaluationMe
             return Temporal.class;
         }
 
+        /**
+         * Indicates that this list is modifiable.
+         */
+        @Override
+        public final Mutability getMutability() {
+            return Mutability.MODIFIABLE;
+        }
+
         /**
          * Removes all dates in this list.
          */
@@ -278,9 +286,9 @@ public class DefaultEvaluationMethod extends ISOMetadata implements EvaluationMe
     /**
      * Constructs an evaluation method initialized to the given description.
      *
-     * @param type  the method type, or {@code null} if none.
-     * @param name  the method description as a {@link String} or an {@link InternationalString} object,
-     *              or {@code null} if none.
+     * @param type         the method type, or {@code null} if none.
+     * @param description  the method description as a {@link String} or an {@link InternationalString} object,
+     *                     or {@code null} if none.
      * @since 1.5
      */
     public DefaultEvaluationMethod(final EvaluationMethodType type, final CharSequence description) {
diff --git a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/parameter/MatrixParameters.java b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/parameter/MatrixParameters.java
index 9f685d0751..e3e34a3378 100644
--- a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/parameter/MatrixParameters.java
+++ b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/parameter/MatrixParameters.java
@@ -130,7 +130,7 @@ import org.apache.sis.util.resources.Errors;
  *     }
  *
  * @author  Martin Desruisseaux (IRD, Geomatys)
- * @version 1.5
+ * @version 1.6
  *
  * @param <E>  the type of matrix element values.
  *
@@ -486,6 +486,17 @@ public class MatrixParameters<E> implements CheckedContainer<E>, Serializable {
         return elementType;
     }
 
+    /**
+     * Indicates that this collection is modifiable (at least by default).
+     *
+     * @return {@link Mutability#MODIFIABLE} by default.
+     * @since 1.6
+     */
+    @Override
+    public Mutability getMutability() {
+        return Mutability.MODIFIABLE;
+    }
+
     /**
      * Returns the number of dimensions of the multi-dimensional array for which this builder will create parameters.
      * The number of array dimensions (matrix order) determines the type of objects represented by the parameters:
diff --git a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/parameter/package-info.java b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/parameter/package-info.java
index 85309408ff..cd7a6e708e 100644
--- a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/parameter/package-info.java
+++ b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/parameter/package-info.java
@@ -85,7 +85,7 @@
  * if the given value is not assignable to the expected class or is not inside the value domain.
  *
  * @author  Martin Desruisseaux (IRD, Geomatys)
- * @version 1.5
+ * @version 1.6
  * @since   0.4
  */
 @XmlSchema(elementFormDefault= XmlNsForm.QUALIFIED, namespace = Namespaces.GML, xmlns = {
diff --git a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/factory/IdentifiedObjectSet.java b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/factory/IdentifiedObjectSet.java
index 9056d04d0a..c3c4f5c59f 100644
--- a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/factory/IdentifiedObjectSet.java
+++ b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/factory/IdentifiedObjectSet.java
@@ -78,7 +78,7 @@ import org.apache.sis.util.collection.CheckedContainer;
  * if they intent to cache {@code IdentifiedObjectSet} instances.
  *
  * @author  Martin Desruisseaux (IRD, Geomatys)
- * @version 1.5
+ * @version 1.6
  *
  * @param <T>  the type of objects to be included in this set.
  *
@@ -149,6 +149,17 @@ public class IdentifiedObjectSet<T extends IdentifiedObject> extends AbstractSet
         return type;
     }
 
+    /**
+     * Indicates that this collection is modifiable (at least by default).
+     *
+     * @return {@link Mutability#MODIFIABLE} by default.
+     * @since 1.6
+     */
+    @Override
+    public Mutability getMutability() {
+        return Mutability.MODIFIABLE;
+    }
+
     /**
      * Removes all of the elements from this collection.
      */
diff --git a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/factory/package-info.java b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/factory/package-info.java
index 594d22f423..f2f3bf9e41 100644
--- a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/factory/package-info.java
+++ b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/factory/package-info.java
@@ -56,7 +56,7 @@
  * </table>
  *
  * @author  Martin Desruisseaux (IRD, Geomatys)
- * @version 1.5
+ * @version 1.6
  * @since   0.6
  */
 package org.apache.sis.referencing.factory;
diff --git a/endorsed/src/org.apache.sis.storage/main/org/apache/sis/io/stream/UpdatableWrite.java b/endorsed/src/org.apache.sis.storage/main/org/apache/sis/io/stream/UpdatableWrite.java
index e62bcbccd2..fa6ea3c694 100644
--- a/endorsed/src/org.apache.sis.storage/main/org/apache/sis/io/stream/UpdatableWrite.java
+++ b/endorsed/src/org.apache.sis.storage/main/org/apache/sis/io/stream/UpdatableWrite.java
@@ -65,9 +65,7 @@ public abstract class UpdatableWrite<V> implements CheckedContainer<V> {
      * This variant can be used when the caller only want to record the position, with no write operation.
      *
      * @param  output  stream where to write the value.
-     * @param  value   the unsigned short value to write.
      * @return handler for modifying the value later.
-     * @throws IOException if an error occurred while writing the value.
      */
     public static UpdatableWrite<Void> of(final ChannelDataOutput output) {
         return new OfVoid(output);
@@ -236,6 +234,16 @@ public abstract class UpdatableWrite<V> implements CheckedContainer<V> {
         }
     }
 
+    /**
+     * Indicates that this container is modifiable.
+     *
+     * @return {@link Mutability#MODIFIABLE}.
+     */
+    @Override
+    public final Mutability getMutability() {
+        return Mutability.MODIFIABLE;
+    }
+
     /**
      * Returns the value size in number of bytes.
      * This is used for checking if there is enough room in a buffer.
diff --git a/endorsed/src/org.apache.sis.util/main/org/apache/sis/math/ArrayVector.java b/endorsed/src/org.apache.sis.util/main/org/apache/sis/math/ArrayVector.java
index e562c67688..351af7ba51 100644
--- a/endorsed/src/org.apache.sis.util/main/org/apache/sis/math/ArrayVector.java
+++ b/endorsed/src/org.apache.sis.util/main/org/apache/sis/math/ArrayVector.java
@@ -163,6 +163,16 @@ abstract class ArrayVector<E extends Number> extends Vector implements CheckedCo
         return null;
     }
 
+    /**
+     * Indicates that this vector is modifiable.
+     *
+     * @return {@link Mutability#MODIFIABLE}.
+     */
+    @Override
+    public final Mutability getMutability() {
+        return Mutability.MODIFIABLE;
+    }
+
     /**
      * Default implementation for the convenience of wrapper of integer types.
      */
diff --git a/endorsed/src/org.apache.sis.util/main/org/apache/sis/math/package-info.java b/endorsed/src/org.apache.sis.util/main/org/apache/sis/math/package-info.java
index 4d8485cb46..55c9097561 100644
--- a/endorsed/src/org.apache.sis.util/main/org/apache/sis/math/package-info.java
+++ b/endorsed/src/org.apache.sis.util/main/org/apache/sis/math/package-info.java
@@ -40,7 +40,7 @@
  * </ul>
  *
  * @author  Martin Desruisseaux (Geomatys)
- * @version 1.4
+ * @version 1.6
  * @since   0.3
  */
 package org.apache.sis.math;
diff --git a/endorsed/src/org.apache.sis.util/main/org/apache/sis/measure/Range.java b/endorsed/src/org.apache.sis.util/main/org/apache/sis/measure/Range.java
index 5f62b5e48b..21334eab86 100644
--- a/endorsed/src/org.apache.sis.util/main/org/apache/sis/measure/Range.java
+++ b/endorsed/src/org.apache.sis.util/main/org/apache/sis/measure/Range.java
@@ -81,7 +81,7 @@ import org.apache.sis.util.collection.CheckedContainer;
  * @author  Joe White
  * @author  Martin Desruisseaux (Geomatys)
  * @author  Jody Garnett (for parameterized type inspiration)
- * @version 1.4
+ * @version 1.6
  *
  * @param <E>  the type of range elements, typically a {@link Number} subclass or {@link java.util.Date}.
  *
@@ -211,6 +211,17 @@ public class Range<E extends Comparable<? super E>> implements CheckedContainer<
         return Comparable.class.isAssignableFrom(elementType);
     }
 
+    /**
+     * Indicates that this range is immutable (at least by default).
+     *
+     * @return {@link Mutability#IMMUTABLE} by default.
+     * @since 1.6
+     */
+    @Override
+    public Mutability getMutability() {
+        return Mutability.IMMUTABLE;
+    }
+
     /**
      * Returns the base type of elements in this range.
      * This is the type specified at construction time.
diff --git a/endorsed/src/org.apache.sis.util/main/org/apache/sis/measure/package-info.java b/endorsed/src/org.apache.sis.util/main/org/apache/sis/measure/package-info.java
index 4f26b26f98..bff8e1a62c 100644
--- a/endorsed/src/org.apache.sis.util/main/org/apache/sis/measure/package-info.java
+++ b/endorsed/src/org.apache.sis.util/main/org/apache/sis/measure/package-info.java
@@ -97,7 +97,7 @@
  *
  * @author  Martin Desruisseaux (MPO, IRD, Geomatys)
  * @author  Alexis Manin (Geomatys)
- * @version 1.5
+ * @version 1.6
  * @since   0.3
  */
 package org.apache.sis.measure;
diff --git a/endorsed/src/org.apache.sis.util/main/org/apache/sis/util/collection/CheckedContainer.java b/endorsed/src/org.apache.sis.util/main/org/apache/sis/util/collection/CheckedContainer.java
index 5fb9dd05b2..dd132e0457 100644
--- a/endorsed/src/org.apache.sis.util/main/org/apache/sis/util/collection/CheckedContainer.java
+++ b/endorsed/src/org.apache.sis.util/main/org/apache/sis/util/collection/CheckedContainer.java
@@ -16,7 +16,13 @@
  */
 package org.apache.sis.util.collection;
 
+import java.util.ArrayDeque;
+import java.util.ArrayList;
 import java.util.Collection;
+import java.util.EnumSet;
+import java.util.HashSet;
+import java.util.LinkedHashSet;
+import java.util.Set;
 
 
 /**
@@ -32,7 +38,7 @@ import java.util.Collection;
  *     }
  *
  * @author  Martin Desruisseaux (IRD, Geomatys)
- * @version 0.3
+ * @version 1.6
  *
  * @param <E>  the base type of elements in the container.
  *
@@ -45,4 +51,80 @@ public interface CheckedContainer<E> {
      * @return the element type.
      */
     Class<E> getElementType();
+
+    /**
+     * Returns whether this container is modifiable, unmodifiable or immutable.
+     *
+     * @return the mutability status of this container.
+     *
+     * @since 1.6
+     */
+    Mutability getMutability();
+
+    /**
+     * Mutability status of a container.
+     *
+     * @since 1.6
+     */
+    enum Mutability {
+        /**
+         * The container is modifiable.
+         * Invoking a setter method should not cause {@link UnsupportedOperationException} to be thrown.
+         */
+        MODIFIABLE,
+
+        /**
+         * The container supports only the removal of elements.
+         * Attempts to add or modify an element will cause {@link UnsupportedOperationException} to be thrown.
+         */
+        REMOVE_ONLY,
+
+        /**
+         * The container is unmodifiable, but not necessarily immutable.
+         * Attempts to add, remove or add an element will cause {@link UnsupportedOperationException} to be thrown.
+         * However, the content of the collection way still change with time, for example if the collection is a view
+         * and the underlying view changes.
+         */
+        UNMODIFIABLE,
+
+        /**
+         * The container is immutable. Its content does not change, and attempts to change
+         * the content will cause {@link UnsupportedOperationException} to be thrown.
+         */
+        IMMUTABLE,
+
+        /**
+         * The mutability status of the container is unknown.
+         */
+        UNKNOWN;
+
+        /**
+         * Hard-coded implementation classes considered as modifiable. We require the exact classes without accepting
+         * subclasses because the latter may override methods in a way that change the mutability of the collection.
+         * This is set is not exhaustive. Its content is determined by Apache <abbr>SIS</abbr> needs.
+         */
+        private static final Set<Class<?>> MUTABLES = Set.of(ArrayDeque.class, ArrayList.class, HashSet.class, LinkedHashSet.class);
+
+        /**
+         * Returns the mutability status of the given collection.
+         * If the given collection implements the {@link CheckedContainer} interface,
+         * then this method returns the {@link #getMutability()} status.
+         * Otherwise, this method tries to guess from the implementation class.
+         * In case of doubt, this method returns {@link #UNKNOWN}.
+         *
+         * @param  collection  the collection for which to get the mutability status.
+         * @return mutability status of the given collection.
+         */
+        public static Mutability of(final Collection<?> collection) {
+            if (collection != null) {
+                if (collection instanceof CheckedContainer<?>) {
+                    return ((CheckedContainer<?>) collection).getMutability();
+                }
+                if (collection instanceof EnumSet<?> || MUTABLES.contains(collection.getClass())) {
+                    return MODIFIABLE;
+                }
+            }
+            return UNKNOWN;
+        }
+    }
 }
diff --git a/endorsed/src/org.apache.sis.util/main/org/apache/sis/util/collection/CodeListSet.java b/endorsed/src/org.apache.sis.util/main/org/apache/sis/util/collection/CodeListSet.java
index 5ae3c3bf2f..8e23bdcdfe 100644
--- a/endorsed/src/org.apache.sis.util/main/org/apache/sis/util/collection/CodeListSet.java
+++ b/endorsed/src/org.apache.sis.util/main/org/apache/sis/util/collection/CodeListSet.java
@@ -49,7 +49,7 @@ import org.apache.sis.util.resources.Errors;
  *   }
  *
  * @author  Martin Desruisseaux (Geomatys)
- * @version 1.5
+ * @version 1.6
  *
  * @param <E>  the type of code list elements in the set.
  *
@@ -159,6 +159,17 @@ public class CodeListSet<E extends CodeList<E>> extends AbstractSet<E>
         return elementType;
     }
 
+    /**
+     * Indicates that this collection is modifiable (at least by default).
+     *
+     * @return {@link Mutability#MODIFIABLE} by default.
+     * @since 1.6
+     */
+    @Override
+    public Mutability getMutability() {
+        return Mutability.MODIFIABLE;
+    }
+
     /**
      * Returns the code list for the given ordinal value. This methods depends
      * only on the code list type; it does not depend on the content of this set.
diff --git a/endorsed/src/org.apache.sis.util/main/org/apache/sis/util/collection/DerivedSet.java b/endorsed/src/org.apache.sis.util/main/org/apache/sis/util/collection/DerivedSet.java
index 802f660aee..ff0a6ae6ab 100644
--- a/endorsed/src/org.apache.sis.util/main/org/apache/sis/util/collection/DerivedSet.java
+++ b/endorsed/src/org.apache.sis.util/main/org/apache/sis/util/collection/DerivedSet.java
@@ -112,6 +112,17 @@ class DerivedSet<S,E> extends SetOfUnknownSize<E> implements CheckedContainer<E>
         return converter.getTargetClass();
     }
 
+    /**
+     * Indicates whether this container is modifiable (which is true by default).
+     *
+     * @return {@link Mutability#MODIFIABLE} by default.
+     * @since 1.6
+     */
+    @Override
+    public final Mutability getMutability() {
+        return Mutability.of(storage);
+    }
+
     /**
      * Declares that this set excludes the null element.
      */
diff --git a/endorsed/src/org.apache.sis.util/main/org/apache/sis/util/collection/RangeSet.java b/endorsed/src/org.apache.sis.util/main/org/apache/sis/util/collection/RangeSet.java
index 3cb37b7299..85b14f69b0 100644
--- a/endorsed/src/org.apache.sis.util/main/org/apache/sis/util/collection/RangeSet.java
+++ b/endorsed/src/org.apache.sis.util/main/org/apache/sis/util/collection/RangeSet.java
@@ -101,7 +101,7 @@ import static org.apache.sis.util.Numbers.*;
  *
  * @author  Martin Desruisseaux (Geomatys)
  * @author  Rémi Maréchal (Geomatys)
- * @version 1.4
+ * @version 1.6
  *
  * @param <E>  the type of range elements.
  *
@@ -303,6 +303,17 @@ public class RangeSet<E extends Comparable<? super E>> extends AbstractSet<Range
         return (Class) Range.class;
     }
 
+    /**
+     * Indicates that this collection is modifiable (at least by default).
+     *
+     * @return {@link Mutability#MODIFIABLE} by default.
+     * @since 1.6
+     */
+    @Override
+    public Mutability getMutability() {
+        return Mutability.MODIFIABLE;
+    }
+
     /**
      * Returns the comparator associated with this sorted set.
      */
diff --git a/endorsed/src/org.apache.sis.util/main/org/apache/sis/util/collection/TableColumn.java b/endorsed/src/org.apache.sis.util/main/org/apache/sis/util/collection/TableColumn.java
index 7f188c629e..1984f92d5f 100644
--- a/endorsed/src/org.apache.sis.util/main/org/apache/sis/util/collection/TableColumn.java
+++ b/endorsed/src/org.apache.sis.util/main/org/apache/sis/util/collection/TableColumn.java
@@ -313,9 +313,22 @@ public class TableColumn<V> implements CheckedContainer<V> {
         return type;
     }
 
+    /**
+     * Indicates that a table header is an immutable object (at least by default).
+     *
+     * @return {@link Mutability#IMMUTABLE} by default.
+     * @since 1.6
+     */
+    @Override
+    public Mutability getMutability() {
+        return Mutability.IMMUTABLE;
+    }
+
     /**
      * Returns a string representation of this table column.
      * The default implementation returns the {@linkplain #getHeader() header} in its default locale.
+     *
+     * @return a string representation of this table column.
      */
     @Override
     public String toString() {
diff --git a/endorsed/src/org.apache.sis.util/main/org/apache/sis/util/collection/TreeNodeList.java b/endorsed/src/org.apache.sis.util/main/org/apache/sis/util/collection/TreeNodeList.java
index 21986080f8..218c8e67c4 100644
--- a/endorsed/src/org.apache.sis.util/main/org/apache/sis/util/collection/TreeNodeList.java
+++ b/endorsed/src/org.apache.sis.util/main/org/apache/sis/util/collection/TreeNodeList.java
@@ -145,6 +145,16 @@ abstract class TreeNodeList extends AbstractList<TreeTable.Node>
         return TreeTable.Node.class;
     }
 
+    /**
+     * Indicates that this container is modifiable.
+     *
+     * @return {@link Mutability#MODIFIABLE}.
+     */
+    @Override
+    public final Mutability getMutability() {
+        return Mutability.MODIFIABLE;
+    }
+
     /**
      * Returns the number of nodes in this list.
      *
diff --git a/endorsed/src/org.apache.sis.util/main/org/apache/sis/util/collection/WeakHashSet.java b/endorsed/src/org.apache.sis.util/main/org/apache/sis/util/collection/WeakHashSet.java
index 1407176957..dab319793c 100644
--- a/endorsed/src/org.apache.sis.util/main/org/apache/sis/util/collection/WeakHashSet.java
+++ b/endorsed/src/org.apache.sis.util/main/org/apache/sis/util/collection/WeakHashSet.java
@@ -150,6 +150,17 @@ public class WeakHashSet<E> extends AbstractSet<E> implements CheckedContainer<E
         return elementType;
     }
 
+    /**
+     * Indicates that this collection is modifiable (at least by default).
+     *
+     * @return {@link Mutability#MODIFIABLE} by default.
+     * @since 1.6
+     */
+    @Override
+    public Mutability getMutability() {
+        return Mutability.MODIFIABLE;
+    }
+
     /**
      * Invoked by {@link Entry} when an element has been collected by the garbage
      * collector. This method removes the weak reference from the {@link #table}.
diff --git a/endorsed/src/org.apache.sis.util/main/org/apache/sis/util/internal/shared/CheckedArrayList.java b/endorsed/src/org.apache.sis.util/main/org/apache/sis/util/internal/shared/CheckedArrayList.java
index 647f5dd526..56aa175387 100644
--- a/endorsed/src/org.apache.sis.util/main/org/apache/sis/util/internal/shared/CheckedArrayList.java
+++ b/endorsed/src/org.apache.sis.util/main/org/apache/sis/util/internal/shared/CheckedArrayList.java
@@ -112,6 +112,16 @@ public final class CheckedArrayList<E> extends ArrayList<E> implements CheckedCo
         return type;
     }
 
+    /**
+     * Indicates that this collection is modifiable.
+     *
+     * @return {@link Mutability#MODIFIABLE}.
+     */
+    @Override
+    public Mutability getMutability() {
+        return Mutability.MODIFIABLE;
+    }
+
     /**
      * Invoked when an illegal element has been given to the {@code add(E)} method.
      * The element may be illegal either because null or because of invalid type.
diff --git a/endorsed/src/org.apache.sis.util/main/org/apache/sis/util/internal/shared/CheckedHashSet.java b/endorsed/src/org.apache.sis.util/main/org/apache/sis/util/internal/shared/CheckedHashSet.java
index 219045667a..0822930f61 100644
--- a/endorsed/src/org.apache.sis.util/main/org/apache/sis/util/internal/shared/CheckedHashSet.java
+++ b/endorsed/src/org.apache.sis.util/main/org/apache/sis/util/internal/shared/CheckedHashSet.java
@@ -81,6 +81,16 @@ public final class CheckedHashSet<E> extends LinkedHashSet<E> implements Checked
         return type;
     }
 
+    /**
+     * Indicates that this collection is modifiable.
+     *
+     * @return {@link Mutability#MODIFIABLE}.
+     */
+    @Override
+    public Mutability getMutability() {
+        return Mutability.MODIFIABLE;
+    }
+
     /**
      * Adds the specified element to this set if it is not already present.
      *
diff --git a/endorsed/src/org.apache.sis.util/main/org/apache/sis/util/internal/shared/UnmodifiableArrayList.java b/endorsed/src/org.apache.sis.util/main/org/apache/sis/util/internal/shared/UnmodifiableArrayList.java
index ece5bb7535..30b0456db3 100644
--- a/endorsed/src/org.apache.sis.util/main/org/apache/sis/util/internal/shared/UnmodifiableArrayList.java
+++ b/endorsed/src/org.apache.sis.util/main/org/apache/sis/util/internal/shared/UnmodifiableArrayList.java
@@ -158,10 +158,20 @@ public class UnmodifiableArrayList<E> extends AbstractList<E> implements RandomA
     @Override
     @ConditionallySafe
     @SuppressWarnings("unchecked")
-    public Class<E> getElementType() {
+    public final Class<E> getElementType() {
         return (Class<E>) array.getClass().getComponentType();
     }
 
+    /**
+     * Indicates that this collection is unmodifiable.
+     *
+     * @return {@link Mutability#UNMODIFIABLE}.
+     */
+    @Override
+    public final Mutability getMutability() {
+        return Mutability.UNMODIFIABLE;
+    }
+
     /**
      * Returns the index of the first valid element.
      * To be overridden by {@link SubList} only.
diff --git a/endorsed/src/org.apache.sis.util/test/org/apache/sis/setup/OptionKeyTest.java b/endorsed/src/org.apache.sis.util/test/org/apache/sis/setup/OptionKeyTest.java
index bece3adb64..cb5205fcf8 100644
--- a/endorsed/src/org.apache.sis.util/test/org/apache/sis/setup/OptionKeyTest.java
+++ b/endorsed/src/org.apache.sis.util/test/org/apache/sis/setup/OptionKeyTest.java
@@ -47,6 +47,10 @@ public final class OptionKeyTest extends TestCase {
         CustomKey(final String name, final Class<T> type) {
             super(name, type);
         }
+
+        @Override public final Mutability getMutability() {
+            return Mutability.IMMUTABLE;
+        }
     }
 
     /**


(sis) 01/02: Avoid spurious errors with XML configuration. This commit does not resolve the problems, it only hides them for now.

Posted by de...@apache.org.
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 4bc9a2c93f1960348379813f0097c5c18dfd123d
Author: Martin Desruisseaux <ma...@geomatys.com>
AuthorDate: Fri Dec 19 19:00:08 2025 +0100

    Avoid spurious errors with XML configuration.
    This commit does not resolve the problems, it only hides them for now.
---
 .../sis/xml/internal/shared/InputFactory.java      | 22 +++++++++++++++++-----
 .../sis/xml/internal/shared/InputFactoryTest.java  |  3 +++
 2 files changed, 20 insertions(+), 5 deletions(-)

diff --git a/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/xml/internal/shared/InputFactory.java b/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/xml/internal/shared/InputFactory.java
index bc7aba5439..a62d1e34cb 100644
--- a/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/xml/internal/shared/InputFactory.java
+++ b/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/xml/internal/shared/InputFactory.java
@@ -18,6 +18,7 @@ package org.apache.sis.xml.internal.shared;
 
 import java.io.Reader;
 import java.io.InputStream;
+import java.util.logging.Logger;
 import javax.xml.XMLConstants;
 import javax.xml.stream.XMLEventReader;
 import javax.xml.stream.XMLInputFactory;
@@ -27,6 +28,8 @@ import javax.xml.stream.util.StreamReaderDelegate;
 import javax.xml.transform.Source;
 import javax.xml.transform.dom.DOMSource;
 import javax.xml.transform.sax.SAXSource;
+import org.apache.sis.system.Loggers;
+import org.apache.sis.util.logging.Logging;
 import org.w3c.dom.Node;
 import org.xml.sax.InputSource;
 
@@ -54,11 +57,20 @@ public final class InputFactory {
      */
     private static final XMLInputFactory FACTORY = XMLInputFactory.newInstance();
     static {
-        if (FACTORY.isPropertySupported(XMLConstants.FEATURE_SECURE_PROCESSING)) {
-            FACTORY.setProperty(XMLConstants.FEATURE_SECURE_PROCESSING, Boolean.TRUE);
-        }
-        if ("all".equals(FACTORY.getProperty(XMLConstants.ACCESS_EXTERNAL_DTD))) {
-            FACTORY.setProperty(XMLConstants.ACCESS_EXTERNAL_DTD, "");
+        try {
+            if (FACTORY.isPropertySupported(XMLConstants.FEATURE_SECURE_PROCESSING)) {
+                FACTORY.setProperty(XMLConstants.FEATURE_SECURE_PROCESSING, Boolean.TRUE);
+            }
+            if ("all".equals(FACTORY.getProperty(XMLConstants.ACCESS_EXTERNAL_DTD))) {
+                FACTORY.setProperty(XMLConstants.ACCESS_EXTERNAL_DTD, "");
+            }
+        } catch (IllegalArgumentException e) {
+            /*
+             * `ACCESS_EXTERNAL_DTD` is clearly documented as a mandatory property since JAXP 1.5 in Java 7.
+             * But Jackson 2.19.1, despite being released 14 years after Java 7, still doesn't support this
+             * property.
+             */
+            Logging.unexpectedException(Logger.getLogger(Loggers.XML), InputFactory.class, "createXMLEventReader", e);
         }
     }
 
diff --git a/endorsed/src/org.apache.sis.metadata/test/org/apache/sis/xml/internal/shared/InputFactoryTest.java b/endorsed/src/org.apache.sis.metadata/test/org/apache/sis/xml/internal/shared/InputFactoryTest.java
index 82ef0427e3..c6bfa7030f 100644
--- a/endorsed/src/org.apache.sis.metadata/test/org/apache/sis/xml/internal/shared/InputFactoryTest.java
+++ b/endorsed/src/org.apache.sis.metadata/test/org/apache/sis/xml/internal/shared/InputFactoryTest.java
@@ -27,6 +27,7 @@ import javax.xml.stream.XMLStreamReader;
 
 // Test dependencies
 import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.Disabled;
 import static org.junit.jupiter.api.Assertions.*;
 import static org.junit.jupiter.api.Assumptions.*;
 import static org.apache.sis.test.Assertions.assertMessageContains;
@@ -65,6 +66,7 @@ public final class InputFactoryTest extends TestCase {
      * @throws XMLStreamException if an error occurred while parsing the <abbr>XML</abbr>.
      */
     @Test
+    @Disabled("JAXP09020006")   // NullPointerException: argument 'catalog' can not be NULL. TODO: test with Maven4.
     public void verifyExternalEntityAccess() throws IOException, XMLStreamException {
         final XMLInputFactory factory = XMLInputFactory.newInstance();
         assumeTrue("all".equals(factory.getProperty(XMLConstants.ACCESS_EXTERNAL_DTD)));
@@ -108,6 +110,7 @@ public final class InputFactoryTest extends TestCase {
      * @throws IOException if an error occurred while writing the test file.
      */
     @Test
+    @Disabled("JAXP09020006")   // NullPointerException: argument 'catalog' can not be NULL. TODO: test with Maven4.
     public void testDisableAccessExternalDTD() throws IOException {
         final XMLInputFactory factory = XMLInputFactory.newInstance();
         factory.setProperty(XMLConstants.ACCESS_EXTERNAL_DTD, "http,https");