Added advanced logging for trace read EOF #250
@ -29,11 +29,14 @@ import de.steamwar.entity.REntityServer;
|
|||||||
import lombok.Cleanup;
|
import lombok.Cleanup;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import lombok.SneakyThrows;
|
import lombok.SneakyThrows;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
import java.io.*;
|
import java.io.*;
|
||||||
import java.lang.ref.SoftReference;
|
import java.lang.ref.SoftReference;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
import java.util.logging.Level;
|
||||||
|
import java.util.logging.Logger;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
import java.util.stream.Stream;
|
import java.util.stream.Stream;
|
||||||
import java.util.zip.GZIPInputStream;
|
import java.util.zip.GZIPInputStream;
|
||||||
@ -308,16 +311,28 @@ public class Trace {
|
|||||||
/**
|
/**
|
||||||
* Loads the records of this trace from storage to memory
|
* Loads the records of this trace from storage to memory
|
||||||
*/
|
*/
|
||||||
@SneakyThrows
|
|
||||||
private void loadRecords() {
|
private void loadRecords() {
|
||||||
List<TNTPoint> records = new ArrayList<>();
|
List<TNTPoint> records = new ArrayList<>();
|
||||||
|
long readBytes = 0;
|
||||||
|
try {
|
||||||
|
FileInputStream fileInputStream = new FileInputStream(recordsSaveFile);
|
||||||
|
|
||||||
FileInputStream fileInputStream = new FileInputStream(recordsSaveFile);
|
@Cleanup
|
||||||
|
ObjectInputStream inputStream = new ObjectInputStream(new GZIPInputStream(fileInputStream));
|
||||||
|
long fileLenght = recordsSaveFile.length();
|
||||||
|
while (fileInputStream.getChannel().position() < fileLenght) {
|
||||||
|
records.add((TNTPoint) inputStream.readObject());
|
||||||
|
readBytes = fileInputStream.getChannel().position();
|
||||||
|
}
|
||||||
|
} catch (EOFException e) {
|
||||||
|
Logger logger = Bukkit.getLogger();
|
||||||
|
logger.log(Level.WARNING, "EOF in trace read detected in " + uuid);
|
||||||
|
logger.log(Level.WARNING, "Read " + readBytes + "/" + recordsSaveFile.length() + " Bytes");
|
||||||
|
logger.log(Level.WARNING, "Read so far: " + records);
|
||||||
|
|
||||||
@Cleanup
|
e.printStackTrace();
|
||||||
ObjectInputStream inputStream = new ObjectInputStream(new GZIPInputStream(fileInputStream));
|
} catch (IOException | ClassNotFoundException e) {
|
||||||
while (fileInputStream.getChannel().position() < recordsSaveFile.length()) {
|
e.printStackTrace();
|
||||||
records.add((TNTPoint) inputStream.readObject());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Map<Integer, List<TNTPoint>> histories = new HashMap<>();
|
Map<Integer, List<TNTPoint>> histories = new HashMap<>();
|
||||||
|
In neuem Issue referenzieren
Einen Benutzer sperren