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
commit cd60520272f299b1214ae38461aa2a0800c14dba Author: Martin Desruisseaux <[email protected]> AuthorDate: Thu Apr 23 16:51:40 2026 +0200 Fix a NullPointerException caused by copying array of image property names in the wrong direction. --- .../main/org/apache/sis/image/BandedSampleConverter.java | 6 ++++-- .../main/org/apache/sis/image/SourceAlignedImage.java | 2 +- .../org/apache/sis/image/internal/shared/BatchComputedImage.java | 7 +++---- 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/endorsed/src/org.apache.sis.feature/main/org/apache/sis/image/BandedSampleConverter.java b/endorsed/src/org.apache.sis.feature/main/org/apache/sis/image/BandedSampleConverter.java index 1c3c2140b4..9cf90055f5 100644 --- a/endorsed/src/org.apache.sis.feature/main/org/apache/sis/image/BandedSampleConverter.java +++ b/endorsed/src/org.apache.sis.feature/main/org/apache/sis/image/BandedSampleConverter.java @@ -301,8 +301,10 @@ class BandedSampleConverter extends WritableComputedImage { */ @Override public String[] getPropertyNames() { - return SourceAlignedImage.filterPropertyNames(getSource().getPropertyNames(), - SourceAlignedImage.POSITIONAL_PROPERTIES, (sampleResolutions != null) ? ADDED_PROPERTIES : null); + return SourceAlignedImage.filterPropertyNames( + getSource().getPropertyNames(), + SourceAlignedImage.POSITIONAL_PROPERTIES, + (sampleResolutions != null) ? ADDED_PROPERTIES : null); } /** diff --git a/endorsed/src/org.apache.sis.feature/main/org/apache/sis/image/SourceAlignedImage.java b/endorsed/src/org.apache.sis.feature/main/org/apache/sis/image/SourceAlignedImage.java index eddc14e495..96c778b03d 100644 --- a/endorsed/src/org.apache.sis.feature/main/org/apache/sis/image/SourceAlignedImage.java +++ b/endorsed/src/org.apache.sis.feature/main/org/apache/sis/image/SourceAlignedImage.java @@ -170,7 +170,7 @@ abstract class SourceAlignedImage extends ComputedImage { return ArraysExt.resize(names, n); } names = ArraysExt.resize(names, n + append.length); - System.arraycopy(names, n, append, 0, append.length); + System.arraycopy(append, 0, names, n, append.length); return names; } diff --git a/endorsed/src/org.apache.sis.feature/main/org/apache/sis/image/internal/shared/BatchComputedImage.java b/endorsed/src/org.apache.sis.feature/main/org/apache/sis/image/internal/shared/BatchComputedImage.java index 61711b5ef0..9aa46cc72d 100644 --- a/endorsed/src/org.apache.sis.feature/main/org/apache/sis/image/internal/shared/BatchComputedImage.java +++ b/endorsed/src/org.apache.sis.feature/main/org/apache/sis/image/internal/shared/BatchComputedImage.java @@ -45,7 +45,7 @@ public abstract class BatchComputedImage extends ComputedImage { * Image properties, or an empty map if none. * May contain instances of {@link DeferredProperty}. */ - private final Map<String,Object> properties; + private final Map<String, Object> properties; /** * Tiles fetched by a calls to {@link #prefetch(Rectangle)}, or {@code null} if none. @@ -89,7 +89,7 @@ public abstract class BatchComputedImage extends ComputedImage { * @param properties image properties ({@link DeferredProperty} supported), or {@code null} if none. * @param sources sources of this image (may be an empty array), or a null array if unknown. */ - protected BatchComputedImage(final SampleModel sampleModel, final Map<String,Object> properties, final RenderedImage... sources) { + protected BatchComputedImage(final SampleModel sampleModel, final Map<String, Object> properties, final RenderedImage... sources) { super(sampleModel, sources); this.properties = (properties != null) ? Map.copyOf(properties) : Map.of(); } @@ -117,8 +117,7 @@ public abstract class BatchComputedImage extends ComputedImage { */ @Override public String[] getPropertyNames() { - final int n = properties.size(); - return (n == 0) ? null : properties.keySet().toArray(new String[n]); + return properties.isEmpty() ? null : properties.keySet().toArray(String[]::new); } /**
