Speed up shutdown and reduce logging

This commit is contained in:
James Seibel
2025-11-14 07:46:10 -06:00
parent 506ba05b34
commit f67fb1758d
2 changed files with 19 additions and 3 deletions
@@ -42,6 +42,8 @@ import com.seibel.distanthorizons.core.wrapperInterfaces.worldGeneration.Abstrac
import com.seibel.distanthorizons.common.wrappers.chunk.ChunkWrapper; import com.seibel.distanthorizons.common.wrappers.chunk.ChunkWrapper;
import java.io.IOException; import java.io.IOException;
import java.nio.channels.ClosedByInterruptException;
import java.nio.channels.ClosedChannelException;
import java.util.*; import java.util.*;
import java.util.concurrent.*; import java.util.concurrent.*;
import java.util.concurrent.atomic.AtomicReference; import java.util.concurrent.atomic.AtomicReference;
@@ -681,12 +683,25 @@ public final class BatchGenerationEnvironment extends AbstractBatchGenerationEnv
actualThrowable = completionException.getCause(); actualThrowable = completionException.getCause();
} }
// interrupts mean the world generator is being shut down, no need to log that
boolean isShutdownException =
actualThrowable instanceof InterruptedException
|| actualThrowable instanceof ClosedByInterruptException;
if (!isShutdownException)
{
CHUNK_LOAD_LOGGER.warn("DistantHorizons: Couldn't load or make chunk ["+chunkPos+"], error: ["+actualThrowable.getMessage()+"].", actualThrowable); CHUNK_LOAD_LOGGER.warn("DistantHorizons: Couldn't load or make chunk ["+chunkPos+"], error: ["+actualThrowable.getMessage()+"].", actualThrowable);
}
return null; return null;
}); });
} }
#endif #endif
} }
catch (ClosedByInterruptException ignore)
{
// this just means the world generator is being shut down
return CompletableFuture.completedFuture(null);
}
catch (Exception e) catch (Exception e)
{ {
CHUNK_LOAD_LOGGER.warn("DistantHorizons: Couldn't load or make chunk [" + chunkPos + "]. Error: [" + e.getMessage() + "].", e); CHUNK_LOAD_LOGGER.warn("DistantHorizons: Couldn't load or make chunk [" + chunkPos + "]. Error: [" + e.getMessage() + "].", e);
@@ -1124,9 +1139,10 @@ public final class BatchGenerationEnvironment extends AbstractBatchGenerationEnv
{ {
regionStorage.close(); regionStorage.close();
} }
catch (ClosedChannelException ignore) { /* world generator is being shut down */ }
catch (IOException e) catch (IOException e)
{ {
EVENT_LOGGER.error("Failed to close region file storage cache!", e); EVENT_LOGGER.error("Failed to close region file storage cache, error: ["+e.getMessage()+"].", e);
} }
} }