From 88519c0325a8a5b348abbb5278eef68920926555 Mon Sep 17 00:00:00 2001 From: vng Date: Mon, 13 Jan 2014 12:36:59 +0300 Subject: [PATCH] Synchronized FileWriter instance creation in FileLogger. --- .../com/mapswithme/util/log/FileLogger.java | 22 ++++++++++++------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/android/src/com/mapswithme/util/log/FileLogger.java b/android/src/com/mapswithme/util/log/FileLogger.java index 20bf02e301..ed331f0ed0 100644 --- a/android/src/com/mapswithme/util/log/FileLogger.java +++ b/android/src/com/mapswithme/util/log/FileLogger.java @@ -7,7 +7,7 @@ import android.util.Log; public class FileLogger extends Logger { - static private FileWriter m_file = null; + static private volatile FileWriter m_file = null; static private String m_separator; private void write(String str) @@ -28,14 +28,20 @@ public class FileLogger extends Logger this.tag = tag; if (m_file == null) { - try + synchronized (FileWriter.class) { - m_file = new FileWriter(path + "android-logging.txt"); - m_separator = System.getProperty("line.separator"); - } - catch (IOException ex) - { - Log.e(tag, ex.toString()); + if (m_file == null) + { + try + { + m_file = new FileWriter(path + "android-logging.txt"); + m_separator = System.getProperty("line.separator"); + } + catch (IOException ex) + { + Log.e(tag, ex.toString()); + } + } } } }