Skip to content

Commit 57e412d

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

File tree

1 file changed

+10
-7
lines changed

1 file changed

+10
-7
lines changed

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

Lines changed: 10 additions & 7 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,18 @@ 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();
236-
} else if (chunkObject == null) {
237-
LOGGER.warn("Timed out awaiting chunk load {}", chunk);
238-
this.requestedChunks.offer(chunk);
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+
}
239242
} else if (PlotSquared.get().isMainThread(Thread.currentThread())) {
240243
this.processChunk(chunkObject);
241244
} else {

0 commit comments

Comments
 (0)