From 6e47eae9036c15080ea0cd07b01d9aa79249dece Mon Sep 17 00:00:00 2001 From: Viktor Lofgren Date: Fri, 13 Sep 2024 16:34:14 +0200 Subject: [PATCH] (index) Correct strange close handling of PositionsFileConstructor --- .../index/construction/PositionsFileConstructor.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/code/index/index-reverse/java/nu/marginalia/index/construction/PositionsFileConstructor.java b/code/index/index-reverse/java/nu/marginalia/index/construction/PositionsFileConstructor.java index 152188a9..808e03fd 100644 --- a/code/index/index-reverse/java/nu/marginalia/index/construction/PositionsFileConstructor.java +++ b/code/index/index-reverse/java/nu/marginalia/index/construction/PositionsFileConstructor.java @@ -63,9 +63,11 @@ public class PositionsFileConstructor implements AutoCloseable { } public void close() throws IOException { - while (workBuffer.position() < workBuffer.limit()) { + if (workBuffer.hasRemaining()) { workBuffer.flip(); - channel.write(workBuffer); + + while (workBuffer.hasRemaining()) + channel.write(workBuffer); } channel.force(false);