6806019: 38 JCK api/javax_sound/midi/ tests fails starting from jdk7 b46
authoramenkov
Fri, 17 Apr 2009 15:15:20 +0400
changeset 2654 64f93f554db6
parent 2653 4abd0886fcfb
child 2655 a69fc05ff63d
6806019: 38 JCK api/javax_sound/midi/ tests fails starting from jdk7 b46 Reviewed-by: kalli
jdk/src/share/classes/com/sun/media/sound/SoftSynthesizer.java
--- a/jdk/src/share/classes/com/sun/media/sound/SoftSynthesizer.java	Fri Apr 17 15:11:43 2009 +0400
+++ b/jdk/src/share/classes/com/sun/media/sound/SoftSynthesizer.java	Fri Apr 17 15:15:20 2009 +0400
@@ -889,9 +889,12 @@
             return;
         }
         synchronized (control_mutex) {
+            Throwable causeException = null;
             try {
-                if (line != null)
+                if (line != null) {
+                    // can throw IllegalArgumentException
                     setFormat(line.getFormat());
+                }
 
                 AudioInputStream ais = openStream(getFormat(), info);
 
@@ -900,10 +903,13 @@
 
                 if (line == null)
                 {
-                    if(testline != null)
+                    if (testline != null) {
                         line = testline;
-                    else
+                    } else {
+                        // can throw LineUnavailableException,
+                        // IllegalArgumentException, SecurityException
                         line = AudioSystem.getSourceDataLine(getFormat());
+                    }
                 }
 
                 double latency = this.latency;
@@ -911,6 +917,8 @@
                 if (!line.isOpen()) {
                     int bufferSize = getFormat().getFrameSize()
                         * (int)(getFormat().getFrameRate() * (latency/1000000f));
+                    // can throw LineUnavailableException,
+                    // IllegalArgumentException, SecurityException
                     line.open(getFormat(), bufferSize);
 
                     // Remember that we opened that line
@@ -954,13 +962,22 @@
                     weakstream.sourceDataLine = sourceDataLine;
                 }
 
-
+            } catch (LineUnavailableException e) {
+                causeException = e;
+            } catch (IllegalArgumentException e) {
+                causeException = e;
+            } catch (SecurityException e) {
+                causeException = e;
+            }
 
-            } catch (LineUnavailableException e) {
+            if (causeException != null) {
                 if (isOpen())
                     close();
                 // am: need MidiUnavailableException(Throwable) ctor!
-                throw new MidiUnavailableException(e.toString());
+                MidiUnavailableException ex = new MidiUnavailableException(
+                        "Can not open line");
+                ex.initCause(causeException);
+                throw ex;
             }
 
         }