From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 From: Aikar Date: Mon, 4 Mar 2013 23:46:10 -0500 Subject: [PATCH] Chunk Save Reattempt We commonly have "Stream Closed" errors on chunk saving, so this code should re-try to save the chunk in the event of failure and hopefully prevent rollbacks. diff --git a/src/main/java/net/minecraft/world/level/chunk/storage/RegionFile.java b/src/main/java/net/minecraft/world/level/chunk/storage/RegionFile.java index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/net/minecraft/world/level/chunk/storage/RegionFile.java +++ b/src/main/java/net/minecraft/world/level/chunk/storage/RegionFile.java @@ -0,0 +0,0 @@ public class RegionFile implements AutoCloseable { return true; } } catch (IOException ioexception) { - com.destroystokyo.paper.exception.ServerInternalException.reportInternalException(ioexception); // Paper + com.destroystokyo.paper.util.SneakyThrow.sneaky(ioexception); // Paper - we want the upper try/catch to retry this return false; } } diff --git a/src/main/java/net/minecraft/world/level/chunk/storage/RegionFileCache.java b/src/main/java/net/minecraft/world/level/chunk/storage/RegionFileCache.java index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/net/minecraft/world/level/chunk/storage/RegionFileCache.java +++ b/src/main/java/net/minecraft/world/level/chunk/storage/RegionFileCache.java @@ -0,0 +0,0 @@ import java.io.IOException; import javax.annotation.Nullable; import net.minecraft.nbt.NBTCompressedStreamTools; import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.server.MinecraftServer; import net.minecraft.util.ExceptionSuppressor; import net.minecraft.world.level.ChunkCoordIntPair; @@ -0,0 +0,0 @@ public final class RegionFileCache implements AutoCloseable { protected void write(ChunkCoordIntPair chunkcoordintpair, NBTTagCompound nbttagcompound) throws IOException { RegionFile regionfile = this.getFile(chunkcoordintpair, false); // CraftBukkit + int attempts = 0; Exception laste = null; while (attempts++ < 5) { try { // Paper DataOutputStream dataoutputstream = regionfile.c(chunkcoordintpair); Throwable throwable = null; @@ -0,0 +0,0 @@ public final class RegionFileCache implements AutoCloseable { } + // Paper start + return; + } catch (Exception ex) { + laste = ex; + } + } + + if (laste != null) { + com.destroystokyo.paper.exception.ServerInternalException.reportInternalException(laste); + MinecraftServer.LOGGER.error("Failed to save chunk", laste); + } + // Paper end } public void close() throws IOException {