Skip to content
Snippets Groups Projects
Commit c000a69f authored by Ximin Luo's avatar Ximin Luo
Browse files

lazily load JNotify to avoid bloating the guice initialization

parent 2bdccef7
No related branches found
No related tags found
No related merge requests found
......@@ -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);
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment