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

StringWriter.flush() is NOOP but documentation does not indicate it

XMLWordPrintable

    • Icon: CSR CSR
    • Resolution: Approved
    • Icon: P4 P4
    • 17
    • core-libs
    • None
    • behavioral
    • minimal
    • No risk as merely a description of existing behavior is added.
    • Java API
    • SE

      Summary

      Clarify the flush methods in java.io classes CharArrayWriter and StringWriter do nothing.

      Problem

      The specification of flush() in the two indicated classes is not explicit about the fact that the methods have no effect.

      Solution

      To the specification of each flush() method add the sentence

      The {@code flush} method of {@code <ClassName/>} does nothing.

      Specification

      --- a/src/java.base/share/classes/java/io/CharArrayWriter.java
      +++ b/src/java.base/share/classes/java/io/CharArrayWriter.java
      @@ -276,6 +276,8 @@ public class CharArrayWriter extends Writer {
      
           /**
            * Flush the stream.
      +     *
      +     * <p> The {@code flush} method of {@code CharArrayWriter} does nothing.
            */
           public void flush() { }
      
      diff --git a/src/java.base/share/classes/java/io/StringWriter.java b/src/java.base/share/classes/java/io/StringWriter.java
      index 16eed62d7bb..30654230ca6 100644
      --- a/src/java.base/share/classes/java/io/StringWriter.java
      +++ b/src/java.base/share/classes/java/io/StringWriter.java
      @@ -229,6 +229,8 @@ public class StringWriter extends Writer {
      
           /**
            * Flush the stream.
      +     *
      +     * <p> The {@code flush} method of {@code StringWriter} does nothing.
            */
           public void flush() {
           }

            bpb Brian Burkhalter
            webbuggrp Webbug Group
            Roger Riggs
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: