mirror of
https://github.com/PaperMC/Paper.git
synced 2024-11-18 16:45:42 +01:00
1c49ff69f4
The hell happened here. : Fix Build 2339ac14a8e Regen the patches 89d3fcbdfaf This new system breaks a lot :(
48 lines
2.1 KiB
Diff
48 lines
2.1 KiB
Diff
From c568c3fd814c8e3d9d6474e8b8078815061163df Mon Sep 17 00:00:00 2001
|
|
From: Suddenly <suddenly@suddenly.coffee>
|
|
Date: Tue, 8 Jul 2014 09:44:18 +1000
|
|
Subject: [PATCH] Safer JSON Loading
|
|
|
|
|
|
diff --git a/src/main/java/net/minecraft/server/JsonList.java b/src/main/java/net/minecraft/server/JsonList.java
|
|
index 61c676a..af2e2d1 100644
|
|
--- a/src/main/java/net/minecraft/server/JsonList.java
|
|
+++ b/src/main/java/net/minecraft/server/JsonList.java
|
|
@@ -149,6 +149,17 @@ public class JsonList {
|
|
try {
|
|
bufferedreader = Files.newReader(this.c, Charsets.UTF_8);
|
|
collection = (Collection) this.b.fromJson(bufferedreader, JsonList.f);
|
|
+ // Spigot Start
|
|
+ } catch ( java.io.FileNotFoundException ex )
|
|
+ {
|
|
+ org.bukkit.Bukkit.getLogger().log( java.util.logging.Level.INFO, "Unable to find file {0}, creating it.", this.c );
|
|
+ } catch ( com.google.gson.JsonSyntaxException ex )
|
|
+ {
|
|
+ org.bukkit.Bukkit.getLogger().log( java.util.logging.Level.WARNING, "Unable to read file {0}, backing it up to {0}.backup and creating new copy.", this.c );
|
|
+ File backup = new File( this.c + ".backup" );
|
|
+ this.c.renameTo( backup );
|
|
+ this.c.delete();
|
|
+ // Spigot End
|
|
} finally {
|
|
IOUtils.closeQuietly(bufferedreader);
|
|
}
|
|
diff --git a/src/main/java/net/minecraft/server/UserCache.java b/src/main/java/net/minecraft/server/UserCache.java
|
|
index 03abfbd..bd35a0f 100644
|
|
--- a/src/main/java/net/minecraft/server/UserCache.java
|
|
+++ b/src/main/java/net/minecraft/server/UserCache.java
|
|
@@ -160,6 +160,11 @@ public class UserCache {
|
|
break label64;
|
|
} catch (FileNotFoundException filenotfoundexception) {
|
|
;
|
|
+ // Spigot Start
|
|
+ } catch (com.google.gson.JsonSyntaxException ex) {
|
|
+ JsonList.a.warn( "Usercache.json is corrupted or has bad formatting. Deleting it to prevent further issues." );
|
|
+ this.g.delete();
|
|
+ // Spigot End
|
|
} finally {
|
|
IOUtils.closeQuietly(bufferedreader);
|
|
}
|
|
--
|
|
2.1.0
|
|
|