Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Unified Diff: src/org/adblockplus/libadblockplus/JniExceptionHandler.java

Issue 6606493159784448: New JNI bindings (Closed)
Patch Set: Added missing empty lines after file comments Created April 2, 2014, 8:49 a.m.
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: src/org/adblockplus/libadblockplus/JniExceptionHandler.java
diff --git a/src/org/adblockplus/libadblockplus/JniExceptionHandler.java b/src/org/adblockplus/libadblockplus/JniExceptionHandler.java
new file mode 100644
index 0000000000000000000000000000000000000000..e147a146a2e24dc35824aba7c8c1ccee4e6a079a
--- /dev/null
+++ b/src/org/adblockplus/libadblockplus/JniExceptionHandler.java
@@ -0,0 +1,70 @@
+/*
+ * This file is part of Adblock Plus <http://adblockplus.org/>,
+ * Copyright (C) 2006-2014 Eyeo GmbH
+ *
+ * Adblock Plus is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 3 as
+ * published by the Free Software Foundation.
+ *
+ * Adblock Plus is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+package org.adblockplus.libadblockplus;
+
+import java.util.concurrent.LinkedBlockingQueue;
+
+public final class JniExceptionHandler
+{
+ private static LogWorker logWorker = null;
+
+ static
+ {
+ logWorker = new LogWorker();
+ final Thread t = new Thread(logWorker);
+ t.setDaemon(true);
+ t.start();
+ }
+
+ public static void logException(final Throwable t)
+ {
+ logWorker.logException(t);
+ }
+
+ private final static class LogWorker implements Runnable
+ {
+ LinkedBlockingQueue<Throwable> exceptionQueue = new LinkedBlockingQueue<Throwable>();
+
+ private void logException(final Throwable t)
+ {
+ this.exceptionQueue.offer(t);
+ }
+
+ @Override
+ public void run()
+ {
+ for (;;)
+ {
+ try
+ {
+ final Throwable t = this.exceptionQueue.take();
+ // TODO: We need a log callback
+ System.err.println("EXCEPTION: " + t);
+ }
+ catch (final InterruptedException ie)
+ {
+ break;
+ }
+ catch (final Throwable ex)
+ {
+ // TODO: Swallow or log?
+ }
+ }
+ }
+ }
+}
« no previous file with comments | « src/org/adblockplus/libadblockplus/FilterEngine.java ('k') | src/org/adblockplus/libadblockplus/JsEngine.java » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld