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 bae538e77a Revert the check for EOFException. Instead, a patch is submitted to OpenJDK for fixing `ImageReaderSpi.canDecodeInput(Object)` implementations. bae538e77a is described below commit bae538e77aa28b36296e1eaac965ae9de7779c53 Author: Martin Desruisseaux <martin.desruisse...@geomatys.com> AuthorDate: Thu May 5 12:51:56 2022 +0200 Revert the check for EOFException. Instead, a patch is submitted to OpenJDK for fixing `ImageReaderSpi.canDecodeInput(Object)` implementations. --- .../sis/internal/storage/image/FormatFilter.java | 22 +++++----------------- 1 file changed, 5 insertions(+), 17 deletions(-) diff --git a/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/image/FormatFilter.java b/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/image/FormatFilter.java index 2b683074dd..8d7bc23350 100644 --- a/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/image/FormatFilter.java +++ b/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/image/FormatFilter.java @@ -28,7 +28,6 @@ import java.io.DataOutput; import java.io.InputStream; import java.io.OutputStream; import java.io.IOException; -import java.io.EOFException; import java.nio.file.Path; import java.awt.image.RenderedImage; import javax.imageio.ImageReader; @@ -39,7 +38,6 @@ import javax.imageio.spi.ImageWriterSpi; import javax.imageio.spi.ImageReaderWriterSpi; import javax.imageio.stream.ImageInputStream; import javax.imageio.stream.ImageOutputStream; -import org.apache.sis.internal.storage.io.ChannelDataInput; import org.apache.sis.storage.StorageConnector; import org.apache.sis.storage.DataStoreException; import org.apache.sis.util.ArraysExt; @@ -145,30 +143,20 @@ enum FormatFilter { for (final Class<?> type : provider.getInputTypes()) { if (ArraysExt.contains(VALID_INPUTS, type)) { final Object input = connector.getStorageAs(type); - final long origin; - if (input instanceof ChannelDataInput) { - origin = ((ChannelDataInput) input).getStreamPosition(); - } else { - origin = -1; - } - if (input != null) try { + if (input != null) { /* * We do not try to mark/reset the input because it should be done * by `canDecodeInput(…)` as per Image I/O contract. Doing our own * mark/reset may interfere with the `canDecodeInput(…)` marks. + * + * Note: `ImageReaderSpi` implementations in Java 18 read up to 8 bytes + * without verifying if those bytes exist. Consequently there is a risk + * of `EOFException` here. A patch has been submitted to OpenJDK. */ if (provider.canDecodeInput(input)) { return provider; } break; // Skip other input types, try the next provider. - } catch (EOFException e) { - /* - * Not all `ImageReader` implementations verify that there is enough bytes in the stream. - * If the stream was our `ChannelDataInput` implementation, we know that we can recover. - * Otherwise conservatively let the exception propagate. - */ - if (origin < 0) throw e; - ((ChannelDataInput) input).seek(origin); } } }