RFR: 8319925: CSS.BackgroundImage incorrectly uses double-checked locking [v2]

Prasanta Sadhukhan psadhukhan at openjdk.org
Tue Dec 5 14:27:41 UTC 2023


On Tue, 5 Dec 2023 14:09:42 GMT, Alexey Ivanov <aivanov at openjdk.org> wrote:

> > > if the URL is invalid, the image isn't loaded
> > 
> > 
> > As per your change, if URL is invalid ie url = null, image is not loaded but `loadedImage` is set to true so it will not give another chance to load the URL again via `CSS.getURL` just in case user decides to call setBase with a valid URL (after finding `getImage `returning null)
> 
> Exactly! The image is **never** given a chance to load for a second time.
> 
> It is how the code has always worked.
>
But it can be a bug in the code that it never gave a chance second time..I think it should get a chance to reload the URL again in case it is invalid the 1st time so I guess the change should be the one where if url is invalid, `loadedImage ` should not be set and it will need a relook at the url (to be set by user)

                  

if (!loadedImage) {
                        URL url = CSS.getURL(base, svalue);
                        if (url != null) {
                            image = new ImageIcon();
                            Image tmpImg = Toolkit.getDefaultToolkit().createImage(url);
                            if (tmpImg != null) {
                                image.setImage(tmpImg);
                            }
                            loadedImage = true;
                        }
                    }

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

PR Comment: https://git.openjdk.org/jdk/pull/16917#issuecomment-1840893445


More information about the client-libs-dev mailing list