From c4e0777a59062ad28c545809acbb62a821fb37b7 Mon Sep 17 00:00:00 2001 From: Fabio Turizo Date: Tue, 26 Mar 2019 13:22:08 -0500 Subject: [PATCH] Implemented fixes for JLine Logging --- .../sun/enterprise/admin/cli/CLICommand.java | 18 +++++++++++++++++- .../enterprise/admin/cli/MultimodeCommand.java | 16 +--------------- 2 files changed, 18 insertions(+), 16 deletions(-) diff --git a/nucleus/admin/cli/src/main/java/com/sun/enterprise/admin/cli/CLICommand.java b/nucleus/admin/cli/src/main/java/com/sun/enterprise/admin/cli/CLICommand.java index 274dfe04552..c907cc0e4eb 100644 --- a/nucleus/admin/cli/src/main/java/com/sun/enterprise/admin/cli/CLICommand.java +++ b/nucleus/admin/cli/src/main/java/com/sun/enterprise/admin/cli/CLICommand.java @@ -133,7 +133,10 @@ public abstract class CLICommand implements PostConstruct { }; private String manpageTokenValues[] = new String[manpageTokens.length]; - + static{ + checkToDisableJLineLogging(); + } + /** * The name of the command. * Initialized in the constructor. @@ -1388,4 +1391,17 @@ private static void file2Set(String file, Set set) { e.printStackTrace(); } } + + private static void checkToDisableJLineLogging(){ + if (Boolean.getBoolean("fish.payara.admin.command.jline.log.disable")) { + System.setProperty("jline.log.jul", "false"); + final OutputStream noOpOutputStream = new OutputStream() { + @Override + public void write(int b) throws IOException { + //NO-OP + } + }; + jline.internal.Log.setOutput(new PrintStream(noOpOutputStream)); + } + } } diff --git a/nucleus/admin/cli/src/main/java/com/sun/enterprise/admin/cli/MultimodeCommand.java b/nucleus/admin/cli/src/main/java/com/sun/enterprise/admin/cli/MultimodeCommand.java index a94e75a9911..fb1264aeeb0 100644 --- a/nucleus/admin/cli/src/main/java/com/sun/enterprise/admin/cli/MultimodeCommand.java +++ b/nucleus/admin/cli/src/main/java/com/sun/enterprise/admin/cli/MultimodeCommand.java @@ -137,8 +137,7 @@ protected Collection usageOptions() { protected int executeCommand() throws CommandException, CommandValidationException { ConsoleReader reader = null; programOpts.setEcho(echo); // restore echo flag, saved in validate - try { - checkToDisableJLineLogging(); + try { if (file == null) { System.out.println(strings.get("multimodeIntro")); reader = new ConsoleReader(ASADMIN, System.in, System.out, null, encoding); @@ -185,19 +184,6 @@ public void write(byte[] b, int off, int len) throws IOException { } } } - - private static void checkToDisableJLineLogging(){ - if (Boolean.getBoolean("fish.payara.admin.command.jline.log.disable")) { - System.setProperty("jline.log.jul", "false"); - final OutputStream noOpOutputStream = new OutputStream() { - @Override - public void write(int b) throws IOException { - //NO-OP - } - }; - jline.internal.Log.setOutput(new PrintStream(noOpOutputStream)); - } - } private static void atomicReplace(ServiceLocator locator, ProgramOptions options) { DynamicConfigurationService dcs = locator.getService(DynamicConfigurationService.class);