< prev index next >

test/lib/testlibrary/jdk/testlibrary/StreamPumper.java

Print this page
rev 1531 : 8171415: Remove Java 7 features from testlibrary
Reviewed-by: omajid

@@ -71,15 +71,15 @@
 
         abstract protected void processLine(String line);
     }
 
     private final InputStream in;
-    private final Set<OutputStream> outStreams = new HashSet<>();
-    private final Set<LinePump> linePumps = new HashSet<>();
+    private final Set<OutputStream> outStreams = new HashSet<OutputStream>();
+    private final Set<LinePump> linePumps = new HashSet<LinePump>();
 
     private final AtomicBoolean processing = new AtomicBoolean(false);
-    private final FutureTask<Void> processingTask = new FutureTask(this, null);
+    private final FutureTask<Void> processingTask = new FutureTask<Void>(this, null);
 
     public StreamPumper(InputStream in) {
         this.in = in;
     }
 

@@ -101,11 +101,13 @@
      * {@code out} until {@code in} has reached end of stream. Abort on
      * interruption. Abort on IOExceptions.
      */
     @Override
     public void run() {
-        try (BufferedInputStream is = new BufferedInputStream(in)) {
+        BufferedInputStream is = null;
+        try {
+            is = new BufferedInputStream(in);
             ByteArrayOutputStream lineBos = new ByteArrayOutputStream();
             byte[] buf = new byte[BUF_SIZE];
             int len = 0;
             int linelen = 0;
 

@@ -154,10 +156,15 @@
             for(OutputStream out : outStreams) {
                 try {
                     out.flush();
                 } catch (IOException e) {}
             }
+            if (is != null) {
+                try {
+                    is.close();
+                } catch (IOException e) {}
+            }
             try {
                 in.close();
             } catch (IOException e) {}
         }
     }
< prev index next >