RFR: 8236987: Remove call to System.out.println from ImageIcon.loadImage [v5]

Tejesh R duke at openjdk.java.net
Fri Mar 25 06:51:47 UTC 2022


On Thu, 24 Mar 2022 19:18:31 GMT, Phil Race <prr at openjdk.org> wrote:

>> src/java.desktop/share/classes/javax/swing/ImageIcon.java line 338:
>> 
>>> 336:             mTracker.removeImage(image, id);
>>> 337: 
>>> 338:             if (interrupted && ((loadStatus & MediaTracker.LOADING )!= 0)) {
>> 
>> Suggestion:
>> 
>>             if (interrupted && ((loadStatus & MediaTracker.LOADING ) != 0)) {
>> 
>> There should be one space on either side of a binary operator.
>
> 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.

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

PR: https://git.openjdk.java.net/jdk/pull/7754



More information about the client-libs-dev mailing list