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

Do Not Print StackTraces to STDERR in Base64TextOutputFormat

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Closed
    • Trivial
    • Resolution: Fixed
    • 3.0.0, 4.0.0
    • 3.2.0, 4.0.0-alpha-1
    • Contrib

    Description

      https://github.com/apache/hive/blob/6d890faf22fd1ede3658a5eed097476eab3c67e9/contrib/src/java/org/apache/hadoop/hive/contrib/fileformat/base64/Base64TextOutputFormat.java

            try {
              String signatureString = job.get("base64.text.output.format.signature");
              if (signatureString != null) {
                signature = signatureString.getBytes("UTF-8");
              } else {
                signature = new byte[0];
              }
            } catch (UnsupportedEncodingException e) {
              e.printStackTrace();
            }
      

      The UnsupportedEncodingException is coming from the getBytes method call. Instead, use the CharSet version of the method and it doesn't throw this explicit exception so the 'try' block can simply be removed. Every JVM will support UTF-8.

      https://docs.oracle.com/javase/7/docs/api/java/lang/String.html#getBytes(java.nio.charset.Charset)
      https://docs.oracle.com/javase/7/docs/api/java/nio/charset/StandardCharsets.html#UTF_8

      Attachments

        1. HIVE-20158.2.patch
          3 kB
          David Mollitor
        2. HIVE-20158.1.patch
          3 kB
          Andrew Sherman

        Activity

          People

            asherman Andrew Sherman
            belugabehr David Mollitor
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: