Skip to content

Commit

Permalink
Fix runtime exception on Java 8 in BufferData.get
Browse files Browse the repository at this point in the history
  • Loading branch information
Col-E committed Jun 8, 2023
1 parent 5896377 commit 46dbad5
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<groupId>software.coley</groupId>
<artifactId>lljzip</artifactId>
<version>1.3.0</version>
<version>1.3.1</version>

<name>LL Java ZIP</name>
<description>Lower level ZIP support for Java</description>
Expand Down
11 changes: 7 additions & 4 deletions src/main/java/software/coley/llzip/util/BufferData.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import java.io.IOException;
import java.io.OutputStream;
import java.nio.Buffer;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;

Expand Down Expand Up @@ -39,11 +40,13 @@ public byte get(long position) {
@Override
public void get(long position, byte[] b, int off, int len) {
ensureOpen();
// Left intentionally as unchained calls due to API differences across Java versions
// and how the compiler changes output.
ByteBuffer buffer = this.buffer;
((ByteBuffer) buffer.slice()
.order(buffer.order())
.position(validate(position)))
.get(b, off, len);
buffer.slice();
buffer.order(buffer.order());
buffer.position(validate(position));
buffer.get(b, off, len);
}

@Override
Expand Down

0 comments on commit 46dbad5

Please sign in to comment.