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

asf-gitbox-commits 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 5f9e157192 Provide more information when a 
`ResourceInternationalString` cannot be deserialized.
5f9e157192 is described below

commit 5f9e1571921ac516e936ea6b5322dae3b36d9750
Author: Martin Desruisseaux <[email protected]>
AuthorDate: Tue May 5 10:54:51 2026 +0200

    Provide more information when a `ResourceInternationalString` cannot be 
deserialized.
---
 .../main/org/apache/sis/util/resources/KeyConstants.java       |  1 +
 .../apache/sis/util/resources/ResourceInternationalString.java | 10 +++++++---
 2 files changed, 8 insertions(+), 3 deletions(-)

diff --git 
a/endorsed/src/org.apache.sis.util/main/org/apache/sis/util/resources/KeyConstants.java
 
b/endorsed/src/org.apache.sis.util/main/org/apache/sis/util/resources/KeyConstants.java
index b815eb45ea..0c66565b3a 100644
--- 
a/endorsed/src/org.apache.sis.util/main/org/apache/sis/util/resources/KeyConstants.java
+++ 
b/endorsed/src/org.apache.sis.util/main/org/apache/sis/util/resources/KeyConstants.java
@@ -103,6 +103,7 @@ public class KeyConstants {
      */
     final String getKeyName(final short index) {
         final int i = Short.toUnsignedInt(index) - IndexedResourceBundle.FIRST;
+        @SuppressWarnings("LocalVariableHidesMemberVariable")
         final String[] keys = getKeyNames();
         if (i >= 0 && i < keys.length) {
             final String key = keys[i];
diff --git 
a/endorsed/src/org.apache.sis.util/main/org/apache/sis/util/resources/ResourceInternationalString.java
 
b/endorsed/src/org.apache.sis.util/main/org/apache/sis/util/resources/ResourceInternationalString.java
index 6af4153494..70fdd4a53c 100644
--- 
a/endorsed/src/org.apache.sis.util/main/org/apache/sis/util/resources/ResourceInternationalString.java
+++ 
b/endorsed/src/org.apache.sis.util/main/org/apache/sis/util/resources/ResourceInternationalString.java
@@ -147,7 +147,7 @@ public abstract class ResourceInternationalString extends 
AbstractInternationalS
         if (object == null || object.getClass() != getClass()) {
             return false;
         }
-        final ResourceInternationalString that = (ResourceInternationalString) 
object;
+        final var that = (ResourceInternationalString) object;
         return (key == that.key) && (hasArguments == that.hasArguments) && 
Objects.deepEquals(arguments, that.arguments);
     }
 
@@ -181,10 +181,14 @@ public abstract class ResourceInternationalString extends 
AbstractInternationalS
      */
     private void readObject(final ObjectInputStream in) throws IOException, 
ClassNotFoundException {
         in.defaultReadObject();
+        final String name = in.readUTF();
         try {
-            key = getKeyConstants().getKeyValue(in.readUTF());
+            key = getKeyConstants().getKeyValue(name);
         } catch (ReflectiveOperationException cause) {
-            throw (InvalidObjectException) new 
InvalidObjectException(cause.toString()).initCause(cause);
+            String message = getBundle(null).getClass().getCanonicalName();
+            message = Errors.format(Errors.Keys.PropertyNotFound_2, message, 
name);
+            throw (InvalidObjectException) new 
InvalidObjectException(message).initCause(cause);
+            // TODO: simplify above line with JDK19.
         }
     }
 }

Reply via email to