Catch all exceptions in jansi initialization. Fixes BUKKIT-4936

Both log4j and our own jline/jansi initialization attempt to catch
errors caused by jansi's use of native libraries. However both of them use
the Exception type which does not catch all errors. On Windows Server 2008
R2 Enterprise without installing extra software the required C++ libraries
are not available which causes an error that does not extend Exception. To
ensure we catch all errors I've changed both of these to catch Throwable
instead which gets us a working console minus jansi functionality.
This commit is contained in:
Travis Watkins 2013-12-02 15:43:55 -06:00
parent f3865064f8
commit 963cd5438a
2 changed files with 2 additions and 2 deletions

View file

@ -116,7 +116,7 @@ public abstract class MinecraftServer implements ICommandListener, Runnable, IMo
try { try {
this.reader = new ConsoleReader(System.in, System.out); this.reader = new ConsoleReader(System.in, System.out);
this.reader.setExpandEvents(false); // Avoid parsing exceptions for uncommonly used event designators this.reader.setExpandEvents(false); // Avoid parsing exceptions for uncommonly used event designators
} catch (Exception e) { } catch (Throwable e) {
try { try {
// Try again with jline disabled for Windows users without C++ 2008 Redistributable // Try again with jline disabled for Windows users without C++ 2008 Redistributable
System.setProperty("jline.terminal", "jline.UnsupportedTerminal"); System.setProperty("jline.terminal", "jline.UnsupportedTerminal");

View file

@ -130,7 +130,7 @@ public final class ConsoleAppender extends AbstractOutputStreamAppender {
LOGGER.debug("Jansi is not installed, cannot find {}", JANSI_CLASS); LOGGER.debug("Jansi is not installed, cannot find {}", JANSI_CLASS);
} catch (final NoSuchMethodException nsme) { } catch (final NoSuchMethodException nsme) {
LOGGER.warn("{} is missing the proper constructor", JANSI_CLASS); LOGGER.warn("{} is missing the proper constructor", JANSI_CLASS);
} catch (final Exception ex) { } catch (final Throwable ex) { // CraftBukkit - Exception -> Throwable
LOGGER.warn("Unable to instantiate {}", JANSI_CLASS); LOGGER.warn("Unable to instantiate {}", JANSI_CLASS);
} }
return printStream; return printStream;