Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8014814

(str) StringBuffer "null" is not appended

XMLWordPrintable

    • b93
    • Verified

      sb1.append("TEST").append((CharSequence)null) , this works as expected.
      But if the second append is called after toString(), "null" is then not appended.

      public class TestAppendNull {
          
          public static void main(String[] args) {
              
              StringBuffer sb1 = new StringBuffer();
              sb1.append("TEST");
              System.out.println(sb1.toString());

              sb1.append((CharSequence)null);
              System.out.println("Expected: TESTnull");
              System.out.println("Result: " + sb1.toString());
          }

      }

      bash-3.2$ $JAVA_HOME/bin/java TestAppendNull
      TEST
      Expected: TESTnull
      Result: TEST


      SQE test
      java_lang/Bug4812591
      failed due to this issue

            dholmes David Holmes
            amlu Amy Lu (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: