changeset 1994:121607fc9843

Don't use jline's internal api to disable logging Backport of: http://icedtea.classpath.org/hg/thermostat/rev/a1c54ac1e54c Reviewed-by: neugens Review-thread: http://icedtea.classpath.org/pipermail/thermostat/2016-June/019958.html PR3058
author Severin Gehwolf <sgehwolf@redhat.com>
date Tue, 15 Mar 2016 11:36:35 -0400
parents 19f86f71ea64
children 116f7c9007cc
files distribution/config/logging.properties distribution/scripts/thermostat launcher/src/main/java/com/redhat/thermostat/launcher/internal/ShellCommand.java
diffstat 3 files changed, 5 insertions(+), 30 deletions(-) [+]
line wrap: on
line diff
--- a/distribution/config/logging.properties	Wed Jun 29 14:22:37 2016 +0200
+++ b/distribution/config/logging.properties	Tue Mar 15 11:36:35 2016 -0400
@@ -73,4 +73,5 @@
 # Other log levels
 ###################################################################
 com.mongodb.level=OFF
+jline=OFF
 
--- a/distribution/scripts/thermostat	Wed Jun 29 14:22:37 2016 +0200
+++ b/distribution/scripts/thermostat	Tue Mar 15 11:36:35 2016 -0400
@@ -54,6 +54,8 @@
 # need tools from the JVM
 TOOLS_JAR="@java.home@/../lib/tools.jar"
 
+JLINE_LOG_ARG="-Djline.log.jul=true"
+
 # This is the minimal boot classpath thermostat needs. Other dependencies
 # will get started by the OSGi framework once that's up.
 SERVICE_CLASSPATH="${THERMOSTAT_LIBS}/org.apache.felix.framework-@felix.framework.version@.jar"
@@ -114,13 +116,13 @@
     if [ x"$PID_FILE" = "x" ]; then
         usage 
     else
-        ${JAVA} "${JAVA_ARGS[@]}" -cp ${SERVICE_CLASSPATH} ${THERMOSTAT_MAIN} "${ARGS[@]}" &
+        ${JAVA} ${JLINE_LOG_ARG} "${JAVA_ARGS[@]}" -cp ${SERVICE_CLASSPATH} ${THERMOSTAT_MAIN} "${ARGS[@]}" &
         retval=$?
         echo $! > $PID_FILE
         retval=$(( $retval + $? ))
     fi
 else
-    ${JAVA} "${JAVA_ARGS[@]}" -cp ${SERVICE_CLASSPATH} ${THERMOSTAT_MAIN} "${ARGS[@]}"
+    ${JAVA} ${JLINE_LOG_ARG} "${JAVA_ARGS[@]}" -cp ${SERVICE_CLASSPATH} ${THERMOSTAT_MAIN} "${ARGS[@]}"
     retval=$?
 fi
 exit $retval
--- a/launcher/src/main/java/com/redhat/thermostat/launcher/internal/ShellCommand.java	Wed Jun 29 14:22:37 2016 +0200
+++ b/launcher/src/main/java/com/redhat/thermostat/launcher/internal/ShellCommand.java	Tue Mar 15 11:36:35 2016 -0400
@@ -117,8 +117,6 @@
         this.prefs = prefs;
         this.shellPrompt = new ShellPrompt();
 
-        disableJlineLogging();
-
         try {
             Map<String, String> promptConfig = config.getConfiguration("shell-command", "shell-prompt.conf");
             this.shellPrompt.overridePromptConfig(promptConfig);
@@ -127,32 +125,6 @@
         }
     }
 
-    private void disableJlineLogging() {
-        /*
-         * newer versions of jline will always log event expansion errors with
-         * stack trace to stderr. Disable that.
-         */
-        OutputStream nullOutputStream = new OutputStream() {
-
-            @Override
-            public void write(int b) throws IOException {
-                // do not write anything
-            }
-
-            @Override
-            public void write(byte[] b) throws IOException {
-                // do not write anything
-            }
-
-            @Override
-            public void write(byte[] b, int off, int len) throws IOException {
-                // do not write anything
-            }
-        };
-
-        jline.internal.Log.setOutput(new PrintStream(nullOutputStream));
-    }
-    
     @Override
     public void run(CommandContext ctx) throws CommandException {
         Terminal term = TerminalFactory.create();