<Swing Dev> [14] RFR JDK-8230235 - Rendering HTML with empty img attribute and documentBaseKey cause Exception

Alexey Ivanov alexey.ivanov at oracle.com
Tue Nov 12 19:57:41 UTC 2019


On 31/10/2019 19:53, Sergey Bylokhov wrote:
> On 10/31/19 5:59 am, Pankaj Bansal wrote:
>> << I guess that the problem is that the "image" is accessed w/o 
>> synchronization on "this" like in other places, but it will be 
>> necessary to add one null check before usage of "image".
>> I have updated the code to access image with synchronization. But 
>> that does not solve the issue. So I have kept the null check also. I 
>> tried to add the null check before calling getWidth, calling getWidth 
>> still makes the image null. So the check before calling getHeight is 
>> still required.
>
> You need to read the image to the local var under synchronization and 
> then get W/H from the local image variable.
> I guess in this case both W/H will be 0 since error is occured?

You're right! This approach seems to be easier to understand.

I think the current code can deadlock: we call image.getWidth() holding 
the monitor of ImageView.this; ImageObserver (line 958) needs to lock 
the monitor of ImageView.this to reset 'image' field to null if an error 
occurred.

If an error occurs, width and height are set to -1.

-- 
Regards,
Alexey


More information about the swing-dev mailing list