RFR: 7903229: ParameterFilter - check initFiles for any File with an empty path

Dmitry Bessonov dbessono at openjdk.org
Thu Sep 1 01:31:22 UTC 2022


On Thu, 1 Sep 2022 00:35:55 GMT, Jonathan Gibbons <jjg at openjdk.org> wrote:

>> ParameterFilter.java : method `update` could check check initFiles (which is result of `stringsToFiles()` call) for any File with an empty path
>
> src/com/sun/javatest/ParameterFilter.java line 241:
> 
>> 239:                     if (file.getPath().isEmpty()) {
>> 240:                         throw new IllegalArgumentException("The passed configuration parameters contain an empty path " +
>> 241:                                 "identifying a test or a folder of tests within the test suite to be run");
> 
> This check seems later than it could be.
> 
> You have a set of Strings (`initStrings`), that get converted to files (`initFiles`) that get converted to back to paths (file.getPath`).
> 
> Why not just check that the strings are not blank in the first place? That being said, how does this code relate to the comment on lines 232,233, that a null or empty check has already been done.
> 
> Finally, what are the implications of throwing unchecked exceptions, like `IllegalArgumentException` in this code?

This specific approach was suggested earlier as-is.  Please see https://bugs.openjdk.org/browse/CODETOOLS-7903229
IAE is a common scenario for this code - e.g. `new InitialUrlFilter(..)` called soon after the check perfectly throws IAE if needed.

-------------

PR: https://git.openjdk.org/jtharness/pull/33


More information about the jtharness-dev mailing list