jdk/test/javax/sound/sampled/AudioInputStream/FrameLengthAfterConversion.java
changeset 45341 b7cc7f639ecf
parent 40718 fe2adbe4d101
--- a/jdk/test/javax/sound/sampled/AudioInputStream/FrameLengthAfterConversion.java	Fri May 05 08:34:22 2017 -0700
+++ b/jdk/test/javax/sound/sampled/AudioInputStream/FrameLengthAfterConversion.java	Sat May 06 13:17:36 2017 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2016, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -94,7 +94,7 @@
         }
     }
 
-    public static void main(final String[] args) {
+    public static void main(final String[] args) throws IOException {
         for (final FormatConversionProvider fcp : load(
                 FormatConversionProvider.class)) {
             System.out.println("fcp = " + fcp);
@@ -139,7 +139,8 @@
      */
     private static void testAfterSaveToStream(final AudioFileWriter afw,
                                               final AudioFileFormat.Type type,
-                                              final AudioInputStream ais) {
+                                              final AudioInputStream ais)
+            throws IOException {
         try {
             final ByteArrayOutputStream out = new ByteArrayOutputStream();
             afw.write(ais, type, out);
@@ -147,7 +148,7 @@
                     out.toByteArray());
             validate(AudioSystem.getAudioInputStream(input).getFrameLength());
         } catch (IllegalArgumentException | UnsupportedAudioFileException
-                | IOException ignored) {
+                ignored) {
         }
     }
 
@@ -156,18 +157,19 @@
      */
     private static void testAfterSaveToFile(final AudioFileWriter afw,
                                             final AudioFileFormat.Type type,
-                                            AudioInputStream ais) {
+                                            AudioInputStream ais)
+            throws IOException {
+        final File temp = File.createTempFile("sound", ".tmp");
         try {
-            final File temp = File.createTempFile("sound", ".tmp");
-            temp.deleteOnExit();
             afw.write(ais, type, temp);
             ais = AudioSystem.getAudioInputStream(temp);
             final long frameLength = ais.getFrameLength();
             ais.close();
-            Files.delete(Paths.get(temp.getAbsolutePath()));
             validate(frameLength);
         } catch (IllegalArgumentException | UnsupportedAudioFileException
-                | IOException ignored) {
+                ignored) {
+        } finally {
+            Files.delete(Paths.get(temp.getAbsolutePath()));
         }
     }