I'm using pdfbox 3.0.0-alpha3
When I use a RandomAccessReadMemoryMappedFile to load a PDDocument, I get a
NullPointerException when I close it after the PDDocument is closed:
try (RandomAccessReadMemoryMappedFile reader = new
RandomAccessReadMemoryMappedFile(file)) {
try (PDDocument doc = Loader.loadPDF(reader, null, null, null, null)) {
// ...
}
}
I found that it's because this.mappedByteBuffer is already null the second time
around, so I think you can just wrap in a not-null check:
public void close() throws IOException {
if (this.fileChannel != null) {
this.fileChannel.close();
}
if (this.mappedByteBuffer != null) { // add this
Optional.ofNullable(this.unmapper).ifPresent((u) -> {
u.accept(this.mappedByteBuffer); // exception is thrown in here
});
this.mappedByteBuffer = null;
}
}
Thanks,
Matt