This is an automated email from the ASF dual-hosted git repository.
jsorel 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 e109a4954d Channel : avoid raising an exception when a flush is called
with an index before current position, call has no effect
e109a4954d is described below
commit e109a4954d540ef6555288e632e2056731b0b092
Author: jsorel <[email protected]>
AuthorDate: Tue Aug 16 16:19:03 2022 +0200
Channel : avoid raising an exception when a flush is called with an index
before current position, call has no effect
---
.../src/main/java/org/apache/sis/internal/storage/io/ChannelData.java | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git
a/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/io/ChannelData.java
b/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/io/ChannelData.java
index d434a7ce24..19b2c50287 100644
---
a/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/io/ChannelData.java
+++
b/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/io/ChannelData.java
@@ -255,11 +255,11 @@ public abstract class ChannelData implements Markable {
*/
public final void flushBefore(final long position) throws IOException {
final long currentPosition = getStreamPosition();
- if (position < bufferOffset || position > currentPosition) {
+ if (position > currentPosition) {
throw new
IndexOutOfBoundsException(Errors.format(Errors.Keys.ValueOutOfRange_4,
"position", bufferOffset, currentPosition, position));
}
- final int n = (int) (position - bufferOffset);
+ final int n = (int) Math.max(position - bufferOffset, 0);
final int p = buffer.position() - n;
final int r = buffer.limit() - n;
flushAndSetPosition(n); // Number of bytes
to forget.