소스 검색

Fix for UTFDataFormatException

GJ 13 년 전
부모
커밋
24d2c1bc7a
2개의 변경된 파일17개의 추가작업 그리고 6개의 파일을 삭제
  1. 2 1
      Changelog.txt
  2. 15 5
      src/main/java/com/gmail/nossr50/util/blockmeta/HashChunkletManager.java

+ 2 - 1
Changelog.txt

@@ -12,7 +12,8 @@ Version 1.3.10-dev
  + Added ability for custom blocks to drop a range of items.
  + Added Ability API functions
  = Fixed players never being removed from memory (memory leak)
- = Fixed admin chat being seen by everyone
+ = Fixed admin chat being seen by everyone
+ = Fixed issue with UTFDataFormatException occurring on occasion when trying to load Chunklets
 
 Version 1.3.09
  + Added compatibility with AntiCheat (Which I highly recommend to prevent cheating)

+ 15 - 5
src/main/java/com/gmail/nossr50/util/blockmeta/HashChunkletManager.java

@@ -8,6 +8,7 @@ import java.io.IOException;
 import java.io.ObjectInputStream;
 import java.io.ObjectOutputStream;
 import java.io.StreamCorruptedException;
+import java.io.UTFDataFormatException;
 import java.util.HashMap;
 
 import org.bukkit.Bukkit;
@@ -235,18 +236,27 @@ public class HashChunkletManager implements ChunkletManager {
             storeIn = (ChunkletStore) objIn.readObject();
             objIn.close();
             fileIn.close();
-        } catch (IOException ex) {
+        }
+        catch (IOException ex) {
             if (ex instanceof EOFException) {
                 // EOF should only happen on Chunklets that somehow have been corrupted.
-                mcMMO.p.getLogger().severe("Chunklet data at " + location.toString() + " could not be read, data in this area will be lost.");
+                mcMMO.p.getLogger().severe("Chunklet data at " + location.toString() + " could not be read due to an EOFException, data in this area will be lost.");
                 return ChunkletStoreFactory.getChunkletStore();
-            } else if (ex instanceof StreamCorruptedException) {
-                // StreamCorrupted happens when the chunklet is no good.
+            }
+            else if (ex instanceof StreamCorruptedException) {
+                // StreamCorrupted happens when the Chunklet is no good.
                 mcMMO.p.getLogger().severe("Chunklet data at " + location.toString() + " is corrupted, data in this area will be lost.");
                 return ChunkletStoreFactory.getChunkletStore();
             }
+            else if (ex instanceof UTFDataFormatException) {
+                // UTF happens when the Chunklet cannot be read or is corrupted
+                mcMMO.p.getLogger().severe("Chunklet data at " + location.toString() + " could not be read due to an UTFDataFormatException, data in this area will be lost.");
+                return ChunkletStoreFactory.getChunkletStore();
+            }
+
             ex.printStackTrace();
-        } catch (ClassNotFoundException ex) {
+        }
+        catch (ClassNotFoundException ex) {
             ex.printStackTrace();
         }