[jdk16] RFR: 8259027: NullPointerException in makeMappedSegment due to NULL Unmapper when length of segment is 0

Maurizio Cimadamore mcimadamore at openjdk.java.net
Tue Jan 5 13:02:03 UTC 2021


When the size of the memory map is zero, FileChannelImpl returns a `null` Unmapper - this creates issues to the mapped memory segment implementation.

To fix, I've created an empty mapped segment class which is initialized to sensible defaults, and whose implenentation of force/load etc. do nothing.

We already had a test for this condition - but the test was missing the `@Test` annotation, so it was not run! I've now beefed up the test a bit to make sure that mapped segment operations do not throw.

-------------

Commit messages:
 - Create subclass for empty mappings
 - Return dummy mapping when mapping length is zero

Changes: https://git.openjdk.java.net/jdk16/pull/83/files
 Webrev: https://webrevs.openjdk.java.net/?repo=jdk16&pr=83&range=00
  Issue: https://bugs.openjdk.java.net/browse/JDK-8259027
  Stats: 46 lines in 2 files changed: 40 ins; 2 del; 4 mod
  Patch: https://git.openjdk.java.net/jdk16/pull/83.diff
  Fetch: git fetch https://git.openjdk.java.net/jdk16 pull/83/head:pull/83

PR: https://git.openjdk.java.net/jdk16/pull/83


More information about the core-libs-dev mailing list