This is an automated email from the ASF dual-hosted git repository. kwin pushed a commit to branch feature/javadoc-for-valuemap-exceptions in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-api.git
commit bfdb8986ac6e01f347e89b2083dc344f0fa3461f Author: Konrad Windszus <[email protected]> AuthorDate: Thu Jun 19 18:52:30 2025 +0200 SLING-12816 Explain which exceptions to expect when writing/reading properties through (Modifiable)ValueMap --- .../java/org/apache/sling/api/resource/ModifiableValueMap.java | 6 +++++- src/main/java/org/apache/sling/api/resource/ValueMap.java | 7 ++++++- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/src/main/java/org/apache/sling/api/resource/ModifiableValueMap.java b/src/main/java/org/apache/sling/api/resource/ModifiableValueMap.java index 572d880..250ba4b 100644 --- a/src/main/java/org/apache/sling/api/resource/ModifiableValueMap.java +++ b/src/main/java/org/apache/sling/api/resource/ModifiableValueMap.java @@ -65,7 +65,11 @@ import org.osgi.annotation.versioning.ConsumerType; * <p> * A modifiable value map must not support deep writes. A call of a modification method * with a path (i.e. a key containing a slash) should result in an {@link IllegalArgumentException}. - * + * <p> + * All write methods may throw any {@link RuntimeException} if the underlying property + * cannot be written some reason (for example if its type is not supported in that location). + * All read methods may throw any {@link RuntimeException} if the underlying property + * cannot be read for some reason (e.g. if the underlying storage is corrupt). * @since 2.2 (Sling API Bundle 2.2.0) */ @ConsumerType diff --git a/src/main/java/org/apache/sling/api/resource/ValueMap.java b/src/main/java/org/apache/sling/api/resource/ValueMap.java index 538aa3c..af4b263 100644 --- a/src/main/java/org/apache/sling/api/resource/ValueMap.java +++ b/src/main/java/org/apache/sling/api/resource/ValueMap.java @@ -40,8 +40,11 @@ import org.osgi.annotation.versioning.ConsumerType; * Only the following methods support deep reads: {@link #get(Object)}, * {@link #get(String, Class)}, {@link #get(String, Object)} and * {@link #containsKey(Object)}. - * + * <p> * A <code>ValueMap</code> should be immutable. + * <p> + * All methods may throw any {@link RuntimeException} if the underlying property + * cannot be read for some reason (e.g. if the underlying storage is corrupt). */ @ConsumerType public interface ValueMap extends Map<String, Object> { @@ -62,6 +65,7 @@ public interface ValueMap extends Map<String, Object> { * @param <T> The class of the type * @return Return named value converted to type T or <code>null</code> if * non existing or can't be converted. + * @throws RuntimeException if the underlying property cannot be accessed */ @SuppressWarnings("unchecked") @Nullable @@ -95,6 +99,7 @@ public interface ValueMap extends Map<String, Object> { * rather rely on {@link #get(String, Class)}. * @return Return named value converted to type T or the default value if * non existing or can't be converted. + * @throws RuntimeException if the underlying property cannot be accessed */ @SuppressWarnings("unchecked") @NotNull
