diff --git a/src/main/java/org/jabref/JabRefException.java b/src/main/java/org/jabref/JabRefException.java index ba3e85a539a..42eacc77c72 100644 --- a/src/main/java/org/jabref/JabRefException.java +++ b/src/main/java/org/jabref/JabRefException.java @@ -5,9 +5,8 @@ public class JabRefException extends Exception { - private String localizedMessage; - private static final Log LOGGER = LogFactory.getLog(JabRefException.class); + private String localizedMessage; public JabRefException(String message) { super(message); @@ -34,7 +33,7 @@ public JabRefException(Throwable cause) { @Override public String getLocalizedMessage() { if (localizedMessage == null) { - LOGGER.warn("No localized message exception message defined. Falling back to getMessage()."); + LOGGER.debug("No localized message exception message defined. Falling back to getMessage()."); return getMessage(); } else { return localizedMessage; diff --git a/src/main/java/org/jabref/gui/logging/GuiAppender.java b/src/main/java/org/jabref/gui/logging/GuiAppender.java index 14e71ac3a80..d6a6f25ebd6 100644 --- a/src/main/java/org/jabref/gui/logging/GuiAppender.java +++ b/src/main/java/org/jabref/gui/logging/GuiAppender.java @@ -2,6 +2,7 @@ import java.io.Serializable; +import org.jabref.gui.util.DefaultTaskExecutor; import org.jabref.logic.logging.LogMessages; import org.apache.logging.log4j.core.Filter; @@ -43,6 +44,6 @@ public static GuiAppender createAppender(@PluginAttribute("name") String name, */ @Override public void append(LogEvent event) { - LogMessages.getInstance().add(event); + DefaultTaskExecutor.runInJavaFXThread(() -> LogMessages.getInstance().add(event)); } } diff --git a/src/main/java/org/jabref/gui/util/DefaultTaskExecutor.java b/src/main/java/org/jabref/gui/util/DefaultTaskExecutor.java index 826ba4aa779..63b0a615cb0 100644 --- a/src/main/java/org/jabref/gui/util/DefaultTaskExecutor.java +++ b/src/main/java/org/jabref/gui/util/DefaultTaskExecutor.java @@ -19,6 +19,21 @@ public class DefaultTaskExecutor implements TaskExecutor { private static final Log LOGGER = LogFactory.getLog(DefaultTaskExecutor.class); + public static V runInJavaFXThread(Callable callable) { + FutureTask task = new FutureTask<>(callable); + Platform.runLater(task); + try { + return task.get(); + } catch (InterruptedException | ExecutionException e) { + LOGGER.error(e); + return null; + } + } + + public static void runInJavaFXThread(Runnable runnable) { + Platform.runLater(runnable); + } + @Override public void execute(BackgroundTask task) { new Thread(getJavaFXTask(task)).start(); @@ -54,16 +69,4 @@ private Exception convertToException(Throwable throwable) { return new Exception(throwable); } } - - public static V runInJavaFXThread(Callable callable) { - FutureTask task = new FutureTask<>(callable); - Platform.runLater(task); - try { - return task.get(); - } catch (InterruptedException | ExecutionException e) { - LOGGER.error(e); - return null; - } - } - }