RFR: 8329098: Support "@1x" image naming convention as fallback [v2]
Michael Strauß
mstrauss at openjdk.org
Fri Oct 18 14:23:32 UTC 2024
On Fri, 18 Oct 2024 13:56:04 GMT, Lukasz Kostyra <lkostyra at openjdk.org> wrote:
>> modules/javafx.graphics/src/main/java/com/sun/javafx/iio/ImageStorage.java line 385:
>>
>>> 383: try {
>>> 384: theStream = ImageTools.createInputStream(input);
>>> 385: } catch (IOException ignored) {
>>
>> It looks like this abstracts away errors like `FileNotFoundException`, and it will do a fallback in all cases, even if it is not a 404 or `FileNotFoundException` -- errors like network problems, permission problems, etc, will also trigger a fallback (likely resulting in the same error). But it could also be a different error, hiding the original problem.
>>
>> In Java we have the option to add a 'surpressed' exception. You could attach it to the 2nd exception, so the original cause of the problem (which could be a permission problem for example) is not lost.
>>
>> Maybe I'm being too picky :)
>
> That is technically solved by re-calling `createInputStream(input)` like @mstr2 suggested to get a correct exception with valid message, so I will go with that approach.
This is a bit minor, but what do you think about storing the previous exception in L385, and then re-throwing it? This is most likely exceedingly rare, but it might be possible that the reason why the previous call to `createInputStream` failed was only transient, we're not 100% sure that we can reproduce the exception by attempting it again.
-------------
PR Review Comment: https://git.openjdk.org/jfx/pull/1598#discussion_r1806583244
More information about the openjfx-dev
mailing list