--- old/./test/javax/imageio/AllowSearch.java 2017-07-11 14:36:46.888455500 +0530 +++ new/./test/javax/imageio/AllowSearch.java 2017-07-11 14:36:45.925665200 +0530 @@ -23,7 +23,7 @@ /* * @test - * @bug 4420318 + * @bug 4420318 8183341 * @summary Checks that an IllegalStateException is thrown by getNumImages(true) * when seekForwardOnly is true * @modules java.desktop/com.sun.imageio.plugins.gif @@ -33,6 +33,8 @@ import java.io.File; import java.io.IOException; +import java.nio.file.Files; +import java.nio.file.Path; import javax.imageio.ImageIO; import javax.imageio.ImageReader; @@ -43,6 +45,7 @@ import com.sun.imageio.plugins.png.PNGImageReader; public class AllowSearch { + private static Path filePath; private static void test(ImageReader reader, String format) throws IOException { @@ -59,6 +62,10 @@ gotISE = true; } + // store the file path to be deleted + filePath = f.toPath(); + stream.close(); + if (!gotISE) { throw new RuntimeException("Failed to get desired exception for " + format + " reader!"); @@ -71,7 +78,16 @@ ImageReader pngReader = new PNGImageReader(null); test(gifReader, "GIF"); + gifReader.dispose(); + Files.delete(filePath); + test(jpegReader, "JPEG"); + jpegReader.dispose(); + Files.delete(filePath); + test(pngReader, "PNG"); + pngReader.dispose(); + Files.delete(filePath); } } +