Hi,
I was able to reproduce the issue and fixed it based on Matts proposal, see [1]
for details
@Matt Thanks for the report and the proposed solution.
Andreas
[1] https://issues.apache.org/jira/browse/PDFBOX-5586
Am 10.04.23 um 17:19 schrieb Matt Bamberger:
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
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@pdfbox.apache.org
For additional commands, e-mail: users-h...@pdfbox.apache.org