Skip to content

Commit

Permalink
tool-core: Add synchronization to fix concurrency problem. Fix #229
Browse files Browse the repository at this point in the history
  • Loading branch information
minborg committed Jan 13, 2017
1 parent 7fcb59e commit 635f635
Showing 1 changed file with 14 additions and 9 deletions.
Expand Up @@ -160,24 +160,24 @@ public void start(Application application, Stage stage) {

LoggerManager.getFactory().addListener(ev -> {
switch (ev.getLevel()) {
case DEBUG : case TRACE : case INFO :
outputMessages.add(OutputUtil.info(ev.getMessage()));
case DEBUG : case TRACE : case INFO : {
addToOutputMessages(OutputUtil.info(ev.getMessage()));
break;
case WARN :
outputMessages.add(OutputUtil.warning(ev.getMessage()));
}
case WARN : {
addToOutputMessages(OutputUtil.warning(ev.getMessage()));
showNotification(ev.getMessage(), Palette.WARNING);
break;
case ERROR : case FATAL :
outputMessages.add(OutputUtil.error(ev.getMessage()));

}
case ERROR : case FATAL : {
addToOutputMessages(OutputUtil.error(ev.getMessage()));
// Hack to remove stack trace from message.
String msg = ev.getMessage();
if (msg.contains("\tat ")) {
msg = msg.substring(0, msg.indexOf("\tat "));
}

showNotification(msg, Palette.ERROR);
break;
}
}
});

Expand All @@ -187,6 +187,11 @@ public void start(Application application, Stage stage) {
}
}

// synchronize to avoid asynchronous calls from logger
private synchronized void addToOutputMessages(Node node) {
outputMessages.add(node);
}

/*************************************************************/
/* Global properties */
/*************************************************************/
Expand Down

0 comments on commit 635f635

Please sign in to comment.