You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@groovy.apache.org by pa...@apache.org on 2018/07/31 09:02:24 UTC

[3/3] groovy git commit: GROOVY-8723: Groovy script output for 2nd and subsequent input files when processing files on command line (ensure System.out isn't closed)

GROOVY-8723: Groovy script output for 2nd and subsequent input files when processing files on command line (ensure System.out isn't closed)


Project: http://git-wip-us.apache.org/repos/asf/groovy/repo
Commit: http://git-wip-us.apache.org/repos/asf/groovy/commit/ed75f134
Tree: http://git-wip-us.apache.org/repos/asf/groovy/tree/ed75f134
Diff: http://git-wip-us.apache.org/repos/asf/groovy/diff/ed75f134

Branch: refs/heads/GROOVY_2_5_X
Commit: ed75f13402d3674a157147d7263bcd6def5b90f7
Parents: 04432d6
Author: Paul King <pa...@asert.com.au>
Authored: Tue Jul 31 17:11:34 2018 +1000
Committer: Paul King <pa...@asert.com.au>
Committed: Tue Jul 31 19:02:08 2018 +1000

----------------------------------------------------------------------
 src/main/groovy/groovy/ui/GroovyMain.java | 13 ++++++-------
 1 file changed, 6 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/groovy/blob/ed75f134/src/main/groovy/groovy/ui/GroovyMain.java
----------------------------------------------------------------------
diff --git a/src/main/groovy/groovy/ui/GroovyMain.java b/src/main/groovy/groovy/ui/GroovyMain.java
index ba7eb71..54e1887 100644
--- a/src/main/groovy/groovy/ui/GroovyMain.java
+++ b/src/main/groovy/groovy/ui/GroovyMain.java
@@ -481,10 +481,10 @@ public class GroovyMain {
         Script s = groovy.parse(getScriptSource(isScriptFile, script));
 
         if (args.isEmpty()) {
-            try(BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
-                PrintWriter writer = new PrintWriter(System.out)) {
-
+            try(BufferedReader reader = new BufferedReader(new InputStreamReader(System.in))) {
+                PrintWriter writer = new PrintWriter(System.out);
                 processReader(s, reader, writer);
+                writer.flush();
             }
         } else {
             Iterator i = args.iterator();
@@ -510,10 +510,10 @@ public class GroovyMain {
 
         if (!editFiles) {
 
-            try(BufferedReader reader = new BufferedReader(new FileReader(file));
-                PrintWriter writer = new PrintWriter(System.out)) {
-
+            try(BufferedReader reader = new BufferedReader(new FileReader(file))) {
+                PrintWriter writer = new PrintWriter(System.out);
                 processReader(s, reader, writer);
+                writer.flush();
             }
         } else {
             File backup;
@@ -530,7 +530,6 @@ public class GroovyMain {
 
             try(BufferedReader reader = new BufferedReader(new FileReader(backup));
                 PrintWriter writer = new PrintWriter(new FileWriter(file))) {
-
                 processReader(s, reader, writer);
             }
         }