Skip to content

Commit

Permalink
Ensure IovArray is usuable without sun.misc.Unsafe (#10870)
Browse files Browse the repository at this point in the history
Motivation:

#10814 did fix a bug where we did try to call memoryAddress() even tho this is not supported. Unfortunally this fix was only applied for one method and so we missed another method which then could throw an exception when we called memoryAddress()

Modifications:

- Also fix the memoryAddress(offset) method.
_ Adjust unit test to also test this.

Result:

Fixes #10813 completely.
  • Loading branch information
normanmaurer committed Dec 16, 2020
1 parent 8ea0d8f commit 882c111
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import org.junit.Test;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotEquals;
import static org.junit.Assert.assertTrue;

public abstract class IovArrayTest {
Expand All @@ -40,6 +41,7 @@ public void testNotFailsWihtoutMemoryAddress() {
assertEquals(16, array.size());
assertTrue(buf.release());
assertTrue(buf2.release());
assertNotEquals(-1, array.memoryAddress(0));
array.release();
assertEquals(0, buffer.refCnt());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ public long maxBytes() {
* Returns the {@code memoryAddress} for the given {@code offset}.
*/
public long memoryAddress(int offset) {
return memory.memoryAddress() + idx(offset);
return memoryAddress + idx(offset);
}

/**
Expand Down

0 comments on commit 882c111

Please sign in to comment.