mirror of
https://github.com/sparrowwallet/sparrow.git
synced 2024-12-25 05:06:45 +00:00
safe multithreading config writes
This commit is contained in:
parent
94897e9744
commit
901a4520fd
1 changed files with 2 additions and 1 deletions
|
@ -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…
Reference in a new issue