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 79369245e4 Declare `nilReasons` as transient for avoiding JAXB in subclasses to inherit it. 79369245e4 is described below commit 79369245e402c9fc36f19a1827d3734fddd6830e Author: Martin Desruisseaux <martin.desruisse...@geomatys.com> AuthorDate: Mon Nov 20 16:56:17 2023 +0100 Declare `nilReasons` as transient for avoiding JAXB in subclasses to inherit it. --- .../main/org/apache/sis/metadata/AbstractMetadata.java | 7 ++++++- .../main/org/apache/sis/metadata/ModifiableMetadata.java | 7 ++++--- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/AbstractMetadata.java b/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/AbstractMetadata.java index f318e6658e..7ed59c8f4c 100644 --- a/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/AbstractMetadata.java +++ b/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/AbstractMetadata.java @@ -90,10 +90,15 @@ public abstract class AbstractMetadata implements LenientComparable, Emptiable { * an exception should have been thrown before. On the other hand, {@code remove(…)} operations may * still be done for removing entries that shouldn't be there. * + * <h4>Serialization</h4> + * This field must be declared transient for preventing JAXB to inherit it in subclasses annotated + * with {@code @XmlAccessorType(XmlAccessType.FIELD)}. Furthermore, serializing the integer values + * would be unstable. We should serialize property names instead. + * * @see NilReasonMap * @see #nilReasons() */ - HashMap<Integer,NilReason> nilReasons; + transient HashMap<Integer,NilReason> nilReasons; /** * Creates an initially empty metadata. diff --git a/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/ModifiableMetadata.java b/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/ModifiableMetadata.java index 542777ca60..e321a3851a 100644 --- a/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/ModifiableMetadata.java +++ b/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/ModifiableMetadata.java @@ -126,9 +126,10 @@ public abstract class ModifiableMetadata extends AbstractMetadata { * Whether this metadata has been made unmodifiable, as one of {@link #EDITABLE}, {@link #FREEZING} * {@link #COMPLETABLE} or {@link #FINAL} values. * - * <p>This field is not yet serialized because we are not sure to keep this information as a byte in - * the future. We could for example use an {@code int} and use remaining bits for caching hash-code - * value of final metadata.</p> + * <h4>Serialization</h4> + * This field must be declared transient for preventing JAXB to inherit it in subclasses annotated + * with {@code @XmlAccessorType(XmlAccessType.FIELD)}. Furthermore, serializing the byte value would + * not be future-proof. */ private transient byte state;