From 5ef308cbee49e46379e20bfb673f1607bea8a28a Mon Sep 17 00:00:00 2001 From: James Seibel Date: Tue, 21 Apr 2026 22:19:57 -0500 Subject: [PATCH] fix rare race condition preventing world gen --- .../generation/queues/LodRequestModule.java | 21 +++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/core/src/main/java/com/seibel/distanthorizons/core/generation/queues/LodRequestModule.java b/core/src/main/java/com/seibel/distanthorizons/core/generation/queues/LodRequestModule.java index c55a2cc4f..c564137e2 100644 --- a/core/src/main/java/com/seibel/distanthorizons/core/generation/queues/LodRequestModule.java +++ b/core/src/main/java/com/seibel/distanthorizons/core/generation/queues/LodRequestModule.java @@ -91,10 +91,27 @@ public class LodRequestModule implements Closeable { try { + // Initial wait is to prevent an issue + // where this starts before the child object's constructor finishes, + // causing null pointers on final non-null references. + // The try-catch in the while loop should also handle this + // but this way we shouldn't have error logs. + Thread.sleep(500); + + // run until the threadpool is shut down while (!Thread.interrupted()) { - Thread.sleep(20); - this.tick(); + try + { + Thread.sleep(20); + + this.tick(); + } + catch (InterruptedException e) { throw e; } + catch (Exception e) + { + LOGGER.error("Unexpected error in [" + LodRequestModule.class.getSimpleName() + "] tick loop, error: [" + e.getMessage() + "].", e); + } } } catch (InterruptedException ignore) { }