Browse Source

safe multithreading config writes

terminal
Craig Raw 4 years ago
parent
commit
901a4520fd
  1. 3
      src/main/java/com/sparrowwallet/sparrow/io/Config.java

3
src/main/java/com/sparrowwallet/sparrow/io/Config.java

@ -277,12 +277,13 @@ public class Config {
flush(); flush();
} }
private void flush() { private synchronized void flush() {
Gson gson = getGson(); Gson gson = getGson();
try { try {
File configFile = getConfigFile(); File configFile = getConfigFile();
Writer writer = new FileWriter(configFile); Writer writer = new FileWriter(configFile);
gson.toJson(this, writer); gson.toJson(this, writer);
writer.flush();
writer.close(); writer.close();
} catch (IOException e) { } catch (IOException e) {
//Ignore //Ignore

Loading…
Cancel
Save