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
commit 8c09e2f76d546fc2d298dcdb28a047c730c13e05 Author: Martin Desruisseaux <[email protected]> AuthorDate: Sat Jul 9 12:19:26 2022 +0200 Finish filling the buffer before to return from LSW decompression method. Documentation fix. --- .../java/org/apache/sis/internal/storage/inflater/LZW.java | 12 ++++++------ .../sis/internal/storage/io/ChannelImageInputStream.java | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/storage/sis-geotiff/src/main/java/org/apache/sis/internal/storage/inflater/LZW.java b/storage/sis-geotiff/src/main/java/org/apache/sis/internal/storage/inflater/LZW.java index 1431d28afc..30de03fb9c 100644 --- a/storage/sis-geotiff/src/main/java/org/apache/sis/internal/storage/inflater/LZW.java +++ b/storage/sis-geotiff/src/main/java/org/apache/sis/internal/storage/inflater/LZW.java @@ -417,7 +417,7 @@ final class LZW extends CompressionChannel { try { entriesForCodes[indexOfFreeEntry] = newEntry; } catch (ArrayIndexOutOfBoundsException e) { - throw (IOException) unexpectedData().initCause(e); + throw (IOException) unexpectedData().initCause(e); // Overflow 12 bit codes. } if (++indexOfFreeEntry == maximumIndex) { if (codeSize < MAX_CODE_SIZE) { @@ -437,11 +437,11 @@ final class LZW extends CompressionChannel { * If the sequence is too long for space available in target buffer, * the writing will be deferred to next invocation of this method. */ - if (stringLength <= target.remaining()) { - target.put(stringsFromCode, stringOffset, stringLength); - } else { - pendingOffset = stringOffset; - pendingLength = stringLength; + final int n = Math.min(stringLength, target.remaining()); + target.put(stringsFromCode, stringOffset, n); + if (n != stringLength) { + pendingOffset = stringOffset + n; + pendingLength = stringLength - n; break; } } diff --git a/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/io/ChannelImageInputStream.java b/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/io/ChannelImageInputStream.java index 770753df9d..9a8a3c0186 100644 --- a/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/io/ChannelImageInputStream.java +++ b/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/io/ChannelImageInputStream.java @@ -244,7 +244,7 @@ loop: while ((c = read()) >= 0) { /** * Skips over <var>n</var> bytes of data from the input stream. - * A negative value move backward in the input stream (some . + * A negative value move backward in the input stream. * * <h4>Design note</h4> * A previous version was skipping no more bytes than the buffer capacity.
