Uploaded image for project: 'Hive'
  1. Hive
  2. HIVE-19700

Workaround for JLine issue with UnsupportedTerminal

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 2.4.0, 3.1.0, 4.0.0
    • Component/s: None
    • Labels:
      None

      Description

      From the JLine's ConsoleReader, readLine(prompt, mask) calls the following beforeReadLine() method.

              try {
                  // System.out.println("is terminal supported " + terminal.isSupported());
                  if (!terminal.isSupported()) {
                      beforeReadLine(prompt, mask);
                  }
      

      So specifically when using UnsupportedTerminal -Djline.terminal and prompt=null and mask!=null, a "null" string gets printed to the console before and after the query result. UnsupportedTerminal is required to be used when running beeline as a background process, hangs otherwise.

          private void beforeReadLine(final String prompt, final Character mask) {
              if (mask != null && maskThread == null) {
                  final String fullPrompt = "\r" + prompt
                      + "                 "
                      + "                 "
                      + "                 "
                      + "\r" + prompt;
      
                  maskThread = new Thread()
                  {
                      public void run() {
                          while (!interrupted()) {
                              try {
                                  Writer out = getOutput();
                                  out.write(fullPrompt);
      

      So the prompt is null and mask is NOT in atleast 2 scenarios in beeline.
      when beeline's silent=true, prompt is null

      When executing beeline in script mode (commands in a file), there should not be any masking while reading lines from the script file. aka, entire line should be a beeline command or part of a multiline hive query.

      So it should be safe to use a null mask instead of ConsoleReader.NULL_MASK when using UnsupportedTerminal as jline terminal.

        Attachments

        1. HIVE-19700.patch
          2 kB
          Naveen Gangam

          Activity

            People

            • Assignee:
              ngangam Naveen Gangam
              Reporter:
              ngangam Naveen Gangam
            • Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: