changeset 7334:54a8fee7f46e 8u20-b19

RT-37565: [Linux] Unit test run dies with too many open files Reviewed-by: kcr
author vadim
date Mon, 16 Jun 2014 21:34:10 +0400
parents 53bde5dff7f2
children 36e12e219f96 34c13f9f4646 7113b281dddf
files modules/graphics/src/test/java/com/sun/javafx/iio/ImageTestHelper.java
diffstat 1 files changed, 7 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/modules/graphics/src/test/java/com/sun/javafx/iio/ImageTestHelper.java	Sun Jun 15 22:17:22 2014 -0700
+++ b/modules/graphics/src/test/java/com/sun/javafx/iio/ImageTestHelper.java	Mon Jun 16 21:34:10 2014 +0400
@@ -53,8 +53,7 @@
     }
 
     static void writeImage(BufferedImage bImg, Object out, String format, String compression) {
-        try {
-            ImageOutputStream ios = ImageIO.createImageOutputStream(out);
+        try (ImageOutputStream ios = ImageIO.createImageOutputStream(out)) {
             Iterator<ImageWriter> iter = ImageIO.getImageWritersByFormatName(format);
             ImageWriter writer = iter.next();
             ImageWriteParam iwp = writer.getDefaultWriteParam();
@@ -63,7 +62,12 @@
                 iwp.setCompressionType(compression);
             }
             writer.setOutput(ios);
-            writer.write(null, new IIOImage(bImg, null, null), iwp);
+            try {
+                writer.write(null, new IIOImage(bImg, null, null), iwp);
+            } finally {
+                writer.dispose();
+                ios.flush();
+            }
         } catch (IOException e) {
             fail("unexpected IOException: " + e);
         }