On Fri, 11 Mar 2022 18:35:21 GMT, Phil Race <p...@openjdk.org> wrote:
>> But in this case it's the waiting thread that is interrupted. The >> `MediaTracker` could complete loading the image successfully yet `ImageIcon` >> instance wouldn't update its `loadStatus` because it removes itself from the >> media tracker. > > We shouldn't be setting any MediaTracker status here - this is the caller ! > It would be absolutely wrong. And it seems likely to me that this println was > put there by the developer of this code who was him/herself not sure if this > would occur and what to do about it so wanted to have a message if it ever > occurred so they could figure out how to handle it. > It seems to me that if the thread were interrupted there'd only be a very > narrow window in which it likely that the image were complete and that if > interrupted then I agree with what I think Alexey is saying which is that the > MediaTracker may not have had a chance to even update status since it was > interrupted .. depends how sophisticated the implementation is. > Since ImageIcon.getLoadStatus() specifies only 3 possible return values then > yes, we should ensure it is one of those . So if it is LOADING then set it to > ABORTED .. However a possible wrinkle is that this call being interrupted may > not actually prevent the separate threads the MediaTracker kicks off from > continuing .. so it may actually be still loading. And it is just that the > waiting was interrupted. > Someone would need to dig into MediaTracker to check. > But since the code removes the image from the tracker .. maybe we don't care ? Since the image is removed from MediaTracker, its status can't change after that. Therefore `LOADING` status should be changed to `ABORTED`. [JDK-6421373](https://bugs.openjdk.java.net/browse/JDK-6421373) has a test case which can be modified to load an image and check `loadStatus` of the image. ------------- PR: https://git.openjdk.java.net/jdk/pull/7754