Skip to content

Commit 6a6c113

Browse files
committed
fix: use orTimeout instead of completing null in chunk coordinator
1 parent 3f573b4 commit 6a6c113

File tree

1 file changed

+13
-6
lines changed

1 file changed

+13
-6
lines changed

Bukkit/src/main/java/com/plotsquared/bukkit/queue/BukkitChunkCoordinator.java

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@
4444
import java.util.Queue;
4545
import java.util.concurrent.LinkedBlockingQueue;
4646
import java.util.concurrent.TimeUnit;
47+
import java.util.concurrent.TimeoutException;
4748
import java.util.concurrent.atomic.AtomicInteger;
4849
import java.util.function.Consumer;
4950

@@ -226,16 +227,22 @@ private void requestBatch() {
226227
loadingChunks.incrementAndGet();
227228
PaperLib
228229
.getChunkAtAsync(this.bukkitWorld, chunk.getX(), chunk.getZ(), shouldGen, true)
229-
.completeOnTimeout(null, 10L, TimeUnit.SECONDS)
230+
.orTimeout(10L, TimeUnit.SECONDS)
230231
.whenComplete((chunkObject, throwable) -> {
231232
loadingChunks.decrementAndGet();
232233
if (throwable != null) {
233-
LOGGER.error("Failed to load chunk {}", chunk, throwable);
234-
// We want one less because this couldn't be processed
235-
this.expectedSize.decrementAndGet();
234+
if (throwable instanceof TimeoutException) {
235+
LOGGER.warn("Timed out awaiting chunk load {}", chunk);
236+
this.requestedChunks.offer(chunk);
237+
} else {
238+
LOGGER.error("Failed to load chunk {}", chunk, throwable);
239+
// We want one less because this couldn't be processed
240+
this.expectedSize.decrementAndGet();
241+
}
236242
} else if (chunkObject == null) {
237-
LOGGER.warn("Timed out awaiting chunk load {}", chunk);
238-
this.requestedChunks.offer(chunk);
243+
if (shouldGen) {
244+
LOGGER.error("Null chunk returned for chunk at {}", chunk);
245+
}
239246
} else if (PlotSquared.get().isMainThread(Thread.currentThread())) {
240247
this.processChunk(chunkObject);
241248
} else {

0 commit comments

Comments
 (0)