From 901a4520fdc15bb3fb8af88243d77a231d809d67 Mon Sep 17 00:00:00 2001 From: Craig Raw Date: Fri, 8 Jan 2021 16:11:36 +0200 Subject: [PATCH] safe multithreading config writes --- src/main/java/com/sparrowwallet/sparrow/io/Config.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/sparrowwallet/sparrow/io/Config.java b/src/main/java/com/sparrowwallet/sparrow/io/Config.java index d5eee569..2ea4b518 100644 --- a/src/main/java/com/sparrowwallet/sparrow/io/Config.java +++ b/src/main/java/com/sparrowwallet/sparrow/io/Config.java @@ -277,12 +277,13 @@ public class Config { flush(); } - private void flush() { + private synchronized void flush() { Gson gson = getGson(); try { File configFile = getConfigFile(); Writer writer = new FileWriter(configFile); gson.toJson(this, writer); + writer.flush(); writer.close(); } catch (IOException e) { //Ignore