From 0cc883b6c31a3123e2361d8d719b024b32f93b28 Mon Sep 17 00:00:00 2001 From: James Seibel Date: Sun, 13 Aug 2023 17:51:10 -0500 Subject: [PATCH] Fix unnecessary region file concurrency warnings in MC 1.16 and 1.17 --- .../RegionFileStorageExternalCache.java | 26 ++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-) diff --git a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/worldGeneration/mimicObject/RegionFileStorageExternalCache.java b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/worldGeneration/mimicObject/RegionFileStorageExternalCache.java index 683937a39..237f41c7a 100644 --- a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/worldGeneration/mimicObject/RegionFileStorageExternalCache.java +++ b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/worldGeneration/mimicObject/RegionFileStorageExternalCache.java @@ -49,11 +49,15 @@ public class RegionFileStorageExternalCache implements AutoCloseable public RegionFile getRegionFile(ChunkPos pos) throws IOException { long posLong = ChunkPos.asLong(pos.getRegionX(), pos.getRegionZ()); - RegionFile rFile; + RegionFile rFile = null; // Check vanilla cache - while (true) + int retryCount = 0; + int maxRetryCount = 8; + while (retryCount < maxRetryCount) { + retryCount++; + try { #if MC_1_16_5 || MC_1_17_1 @@ -66,10 +70,26 @@ public class RegionFileStorageExternalCache implements AutoCloseable } catch (ArrayIndexOutOfBoundsException e) { - BatchGenerationEnvironment.LOAD_LOGGER.warn("Concurrency issue detected when getting region file for chunk at " + pos + ". Retrying..."); + #if MC_1_16_5 || MC_1_17_1 + // the file just wasn't cached + break; + #else + // potential concurrency issue, wait a second and try to get the file again + try + { + Thread.sleep(250); + } + catch (InterruptedException ignored) { } + #endif } } + if (retryCount >= maxRetryCount) + { + BatchGenerationEnvironment.LOAD_LOGGER.warn("Concurrency issue detected when getting region file for chunk at " + pos + "."); + } + + if (rFile != null) { return rFile;