<Sound Dev> [9] Review Request: 8135100 Behavior of null arguments not specified in javax.sound.sampled.spi
Sergey Bylokhov
Sergey.Bylokhov at oracle.com
Mon Sep 14 13:29:55 UTC 2015
Hello Audio Guru.
Please review the fix for jdk9. This issue is a subtask of:
4912693: Behavior of null arguments not specified in Java Sound
In this patch I cover the whole javax.sound.sampled.spi package.
The small description of the fix:
- I have checked all methods in the spi package and all related methods
in AudioSystem class.
- I have moved related tests to the folder corresponding the package and
class name.
- I have written a tests for every method and class which I changed.
Note that these classes related to the different service providers, so I
have covered all installed implementations of each provider.
Long description.
I splits the fix to 3 use cases:
- If the method always throw a NPE, then I simply update a javadoc and
write a small test.
- If the method most of the time throw a NPE then I update a javadoc and
change the method to always throw a NPE. Also I write a test which tries
to emulate both cases when NPE was thrown and when not. For example
AudioFileWriter.isFileTypeSupported(Type) always throws a NPE if at
least one type is supported, but if the array is empty then false is
returned.
- If the method have a few parameters and throw a NPE for some set of
them. For example AudioFloatFormatConverter.
isConversionSupported(Encoding,AudioFormat), the appropriate test tries
to cover these cases.
It turned out that all methods throw a NPE except of one:
AudioSystem.getMixer()(MixerProvider.getMixer()), but it was found that
the specification of MixerProvider.getMixer has no information about the
null, so I copied it from the AudioSystem.getMixer(). Also one
implementation of MixerProvider - PortMixerProvider.getMixer() throws
NPE, so updated its implementation to the same as
DirectAudioDeviceProvider.getMixer();
I have done all related regression/jck/sqe tests, and I found one issue
in jck and regression tests. Both are related to JDK-4941629 [1] (see
comments in this CR). The jck test assumes that the method
AudioSystem.write(ais, null, stream) should throw
IllegalArgumentException. But according to specification it should throw
IllegalArgumentException if the type is unsupported, but the related
method AudioSystem.isFileTypeSupported(Type) will always throw a NPE
for null. I prefer to file a bug against jck for this case.
[1] https://bugs.openjdk.java.net/browse/JDK-4941629
Bug: https://bugs.openjdk.java.net/browse/JDK-8135100
The new test: http://cr.openjdk.java.net/~serb/8135100/webrev.01
--
Best regards, Sergey.
More information about the sound-dev
mailing list