Uploaded image for project: 'Groovy'
  1. Groovy
  2. GROOVY-9014

printf does not respect "out" property

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 3.0.0-beta-1, 2.5.7
    • Component/s: groovy-runtime
    • Labels:
      None
    • Environment:
      Ubuntu 18.04.1,

      Description

      I am using groovy to run dynamic scripts from my Java application. I use JSR223 for this. I am overriding "out" property to redirect script stdout to my own consumer. However, I've noticed that printf inside closures does not respect that property (it always prints to stdout) while println perfectly complies (and prints to whatever specified).

       

      I beleive this is because of the differences in printf and println in DefaultGroovyMethods.java: in https://github.com/apache/groovy/blob/master/src/main/java/org/codehaus/groovy/runtime/DefaultGroovyMethods.java#L849

      println uses closure owner while printf does simple System.out.

        Attachments

        1. test.groovy
          0.6 kB
          Pavel Melnikov

          Issue Links

            Activity

              People

              • Assignee:
                paulk Paul King
                Reporter:
                positron96 Pavel Melnikov
              • Votes:
                0 Vote for this issue
                Watchers:
                3 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:

                  Time Tracking

                  Estimated:
                  Original Estimate - Not Specified
                  Not Specified
                  Remaining:
                  Remaining Estimate - 0h
                  0h
                  Logged:
                  Time Spent - 20m
                  20m