groovy
  1. groovy
  2. GROOVY-3235

DGM.println(Object) and friends do a Writer.close() if the object is a writer. Should be flush() instead.

    Details

    • Type: Bug Bug
    • Status: Closed Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 1.5.7, 1.6-rc-1
    • Fix Version/s: 1.6-rc-2, 1.5.8
    • Component/s: None
    • Labels:
      None
    • Testcase included:
      yes
    • Number of attachments :
      0

      Description

      The DefaultGroovyMethods:

      print(Object)
      println(Object)
      print(Object, Object)
      println(Object, Object)

      all will create a PrintWriter and then do a Writer.close() if self is a Writer. That will close the underlying writer, which is definitely the wrong thing.

      The correct behavior is to do a flush().

      It is easy to see that flushing rather than closing is the right thing by looking at what happens if self is not a Writer. In that case System.out.print(ln) is called and System.out is not closed.

        Activity

        Hide
        blackdrag blackdrag added a comment -

        so what about the issue? The fix is done... what is missing?

        Show
        blackdrag blackdrag added a comment - so what about the issue? The fix is done... what is missing?
        Hide
        Jim White added a comment -

        Committed to 1.6 (cs14853).

        Show
        Jim White added a comment - Committed to 1.6 (cs14853).
        Hide
        Jim White added a comment -

        Committed to 1.5 (14854).

        Show
        Jim White added a comment - Committed to 1.5 (14854).
        Hide
        Roshan Dawrani added a comment -

        The local build on my windows XP machine is failing because of Groovy3235Bug.testBug(). You may want to check. Below is the error details that show up in the log:

        Caused an ERROR
        Expression: (d == t). Values: d = This is one line.
        This is another.
        All these lines should be written.
        , t = This is one line.
        This is another.
        All these lines should be written.

        java.lang.AssertionError: Expression: (d == t). Values: d = This is one line.
        This is another.
        All these lines should be written.
        , t = This is one line.
        This is another.
        All these lines should be written.

        at org.codehaus.groovy.runtime.InvokerHelper.assertFailed(InvokerHelper.java:373)
        at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.assertFailed(ScriptBytecodeAdapter.java:658)
        at groovy.bugs.Groovy3235Bug.testBug(Groovy3235Bug.groovy:18)

        Show
        Roshan Dawrani added a comment - The local build on my windows XP machine is failing because of Groovy3235Bug.testBug(). You may want to check. Below is the error details that show up in the log: Caused an ERROR Expression: (d == t). Values: d = This is one line. This is another. All these lines should be written. , t = This is one line. This is another. All these lines should be written. java.lang.AssertionError: Expression: (d == t). Values: d = This is one line. This is another. All these lines should be written. , t = This is one line. This is another. All these lines should be written. at org.codehaus.groovy.runtime.InvokerHelper.assertFailed(InvokerHelper.java:373) at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.assertFailed(ScriptBytecodeAdapter.java:658) at groovy.bugs.Groovy3235Bug.testBug(Groovy3235Bug.groovy:18)
        Hide
        Roshan Dawrani added a comment -

        I have verified both on 1.5.x and 1.6.x dev branches and both builds are failing for me.

        Show
        Roshan Dawrani added a comment - I have verified both on 1.5.x and 1.6.x dev branches and both builds are failing for me.

          People

          • Assignee:
            Jim White
            Reporter:
            Jim White
          • Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: