Handle and report exception thrown by checkstyle
Change-Id: I041fd0d4787ddff80a206e47688524984f3500ff
diff --git a/tools/build/conf/src/main/java/org/onosproject/buckdaemon/BuckDaemon.java b/tools/build/conf/src/main/java/org/onosproject/buckdaemon/BuckDaemon.java
index ce8a78c..5b37609 100644
--- a/tools/build/conf/src/main/java/org/onosproject/buckdaemon/BuckDaemon.java
+++ b/tools/build/conf/src/main/java/org/onosproject/buckdaemon/BuckDaemon.java
@@ -21,6 +21,7 @@
import org.onosproject.checkstyle.CheckstyleRunner;
import java.io.IOException;
+import java.io.PrintStream;
import java.net.ServerSocket;
import java.net.Socket;
import java.nio.ByteBuffer;
@@ -176,9 +177,14 @@
BuckTask task = tasks.get(taskName);
if (task != null) {
System.out.println(String.format("Executing task '%s'", taskName));
- task.execute(context);
- for (String line : context.output()) {
- output(socket, line);
+ try {
+ task.execute(context);
+ for (String line : context.output()) {
+ output(socket, line);
+ }
+ // TODO should we catch Exception, RuntimeException, or something specific?
+ } catch (Throwable e) {
+ e.printStackTrace(new PrintStream(socket.getOutputStream()));
}
} else {
String message = String.format("No task named '%s'", taskName);
diff --git a/tools/build/conf/src/main/java/org/onosproject/checkstyle/CheckstyleRunner.java b/tools/build/conf/src/main/java/org/onosproject/checkstyle/CheckstyleRunner.java
index 25f3d53..65023b1 100644
--- a/tools/build/conf/src/main/java/org/onosproject/checkstyle/CheckstyleRunner.java
+++ b/tools/build/conf/src/main/java/org/onosproject/checkstyle/CheckstyleRunner.java
@@ -91,6 +91,7 @@
listener.await();
} catch (CheckstyleException | InterruptedException e) {
+ e.printStackTrace(); //dump exeception to stderr
throw new RuntimeException(e);
} finally {
checker.destroy();