Mirror von
https://github.com/PaperMC/Paper.git
synchronisiert 2024-12-16 11:30:06 +01:00
52 Zeilen
2.5 KiB
Diff
52 Zeilen
2.5 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
From: Aikar <aikar@aikar.co>
|
|
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/server/RegionFile.java b/src/main/java/net/minecraft/server/RegionFile.java
|
|
index d2977022d163edc5518dd4737c30cffd3eff5954..26b55108ecf4cd48762b00da625b0ce1d2f42c67 100644
|
|
--- a/src/main/java/net/minecraft/server/RegionFile.java
|
|
+++ b/src/main/java/net/minecraft/server/RegionFile.java
|
|
@@ -246,7 +246,7 @@ 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/server/RegionFileCache.java b/src/main/java/net/minecraft/server/RegionFileCache.java
|
|
index 4d1de29e7c4bea266c544917fbe807a0b19462d6..4cff831de2128cd346f1f1627f0915d534b0d3bf 100644
|
|
--- a/src/main/java/net/minecraft/server/RegionFileCache.java
|
|
+++ b/src/main/java/net/minecraft/server/RegionFileCache.java
|
|
@@ -87,6 +87,7 @@ 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;
|
|
|
|
@@ -110,6 +111,18 @@ 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 {
|