|
44 | 44 | import java.util.Queue; |
45 | 45 | import java.util.concurrent.LinkedBlockingQueue; |
46 | 46 | import java.util.concurrent.TimeUnit; |
| 47 | +import java.util.concurrent.TimeoutException; |
47 | 48 | import java.util.concurrent.atomic.AtomicInteger; |
48 | 49 | import java.util.function.Consumer; |
49 | 50 |
|
@@ -226,16 +227,18 @@ private void requestBatch() { |
226 | 227 | loadingChunks.incrementAndGet(); |
227 | 228 | PaperLib |
228 | 229 | .getChunkAtAsync(this.bukkitWorld, chunk.getX(), chunk.getZ(), shouldGen, true) |
229 | | - .completeOnTimeout(null, 10L, TimeUnit.SECONDS) |
| 230 | + .orTimeout(10L, TimeUnit.SECONDS) |
230 | 231 | .whenComplete((chunkObject, throwable) -> { |
231 | 232 | loadingChunks.decrementAndGet(); |
232 | 233 | 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 | + } |
239 | 242 | } else if (PlotSquared.get().isMainThread(Thread.currentThread())) { |
240 | 243 | this.processChunk(chunkObject); |
241 | 244 | } else { |
|
0 commit comments