mirror of
https://github.com/plan-player-analytics/Plan.git
synced 2024-09-28 22:47:38 +02:00
Catch session deserialization errors during enable
This commit is contained in:
parent
85b4a51515
commit
97b9a18cea
@ -120,7 +120,7 @@ public class ShutdownDataPreservation extends TaskSystem.Task {
|
|||||||
List<FinishedSession> loadFinishedSessions() {
|
List<FinishedSession> loadFinishedSessions() {
|
||||||
if (!Files.exists(storeLocation)) return Collections.emptyList();
|
if (!Files.exists(storeLocation)) return Collections.emptyList();
|
||||||
try (Stream<String> lines = Files.lines(storeLocation)) {
|
try (Stream<String> lines = Files.lines(storeLocation)) {
|
||||||
return lines.map(FinishedSession::deserializeCSV)
|
return lines.map(this::deserializeToSession)
|
||||||
.filter(Optional::isPresent)
|
.filter(Optional::isPresent)
|
||||||
.map(Optional::get)
|
.map(Optional::get)
|
||||||
.collect(Collectors.toList());
|
.collect(Collectors.toList());
|
||||||
@ -129,6 +129,15 @@ public class ShutdownDataPreservation extends TaskSystem.Task {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private Optional<FinishedSession> deserializeToSession(String line) {
|
||||||
|
try {
|
||||||
|
return FinishedSession.deserializeCSV(line);
|
||||||
|
} catch (Exception e) {
|
||||||
|
logger.warn("Ignoring line '" + line + "' in unsaved-sessions.csv due to: " + e);
|
||||||
|
return Optional.empty();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void preserveSessionsInCache() {
|
public void preserveSessionsInCache() {
|
||||||
long now = System.currentTimeMillis();
|
long now = System.currentTimeMillis();
|
||||||
List<FinishedSession> finishedSessions = SessionCache.getActiveSessions().stream()
|
List<FinishedSession> finishedSessions = SessionCache.getActiveSessions().stream()
|
||||||
|
Loading…
Reference in New Issue
Block a user