RFR: 8236987: Remove call to System.out.println from ImageIcon.loadImage [v5]
Alexey Ivanov
aivanov at openjdk.java.net
Mon Mar 28 19:53:47 UTC 2022
On Fri, 25 Mar 2022 06:48:22 GMT, Tejesh R <duke at openjdk.java.net> wrote:
>> It seems to me that as I mentioned there's at least a possibility that the image actually is loaded. This thread being interrupted doesn't stop the Media loading threads.
>>
>> Since there's only one image for this id, LOADING and COMPLETE ought to be
>> mutually exclusive. In fact I'd expect only one of the flags to be set.
>>
>> So I can I suppose see the logic that this API returning ABORTED instead of LOADING
>> makes sense, but that is because this method removes it from the tracker ..
>>
>> So I guess I can live with it .. especially since I think this an unlikely scenario.
>>
>> I can see both points of view on whether interrupted is needed.
>> I'd be inclined to keep it since then you can PROVE that there's a change of behaviour only if interrupted.
>
> There is a change of Behavior if its interrupted, for Not-Interrupted case the result would be ERRORED for url link and COMPLETE for local Image, but for Interrupted case the result would be LOADING for both, which we are changing to ABORTED.
> It seems to me that as I mentioned there's at least a possibility that the image actually is loaded. This thread being interrupted doesn't stop the Media loading threads.
No, it doesn't.
>Since there's only one image for this id, LOADING and COMPLETE ought to be
mutually exclusive. In fact I'd expect only one of the flags to be set.
Right. At least I came to this conclusion: only one of the status constants is used although they're treated like flags in the code.
> So I can I suppose see the logic that this API returning ABORTED instead of LOADING
makes sense, but that is because this method removes it from the tracker ..
Since the image is removed from MediaTracker, it cannot update its status even if loading completes at a later time. This is why I think the API should return `ABORTED` instead of `LOADING`.
> …for Not-Interrupted case the result would be ERRORED for url link and COMPLETE for local Image,
Why? It could be `COMPLETE` for either. If the image from the URL is loaded successfully, its status will be `COMPLETE`.
> but for Interrupted case the result would be LOADING for both, which we are changing to ABORTED.
Again, not necessarily. In the test, the thread is interrupted before the image is added to MediaTracker. As soon as `waitForID` is called, it immediately throws `InterruptedException`. This is why the image status is likely to be `LOADING`.
-------------
PR: https://git.openjdk.java.net/jdk/pull/7754
More information about the client-libs-dev
mailing list