From c000a69f5b9473be4ad1503947155888b3c52171 Mon Sep 17 00:00:00 2001 From: Ximin Luo <infinity0@pwned.gg> Date: Wed, 29 Jan 2014 20:36:04 +0000 Subject: [PATCH] lazily load JNotify to avoid bloating the guice initialization --- .../plugins/file/UnixRemovableDriveMonitor.java | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/briar-desktop/src/org/briarproject/plugins/file/UnixRemovableDriveMonitor.java b/briar-desktop/src/org/briarproject/plugins/file/UnixRemovableDriveMonitor.java index 8c4edee5f5..5a57b316d0 100644 --- a/briar-desktop/src/org/briarproject/plugins/file/UnixRemovableDriveMonitor.java +++ b/briar-desktop/src/org/briarproject/plugins/file/UnixRemovableDriveMonitor.java @@ -19,7 +19,8 @@ JNotifyListener { protected abstract String[] getPathsToWatch(); - final private static Throwable loadError = tryLoad(); + private static boolean triedLoad = false; + private static Throwable loadError = null; private static Throwable tryLoad() { try { @@ -32,7 +33,11 @@ JNotifyListener { } } - public static void checkEnabled() throws IOException { + public static synchronized void checkEnabled() throws IOException { + if (!triedLoad) { + loadError = tryLoad(); + triedLoad = true; + } if (loadError != null) { throw new IOException("JNotify not loaded", loadError); } -- GitLab