<AWT Dev> [9] Review request for 8132706 [macosx] Toolkit.getImage() throws NPE for null URL

Semyon Sadetsky semyon.sadetsky at oracle.com
Fri Apr 15 22:09:31 UTC 2016


On 4/15/2016 10:26 PM, Phil Race wrote:
> I touched on this several emails ago. An unresponsive URL may simply 
> never produce an Image.
> If we wanted to handle it like that we could, but it would have to be 
> explicit.
> And I don't know if you could justify the same for the method that 
> takes a File.
It depends on the chosen approach, strict or flexible. Any i/o operation 
is unreliable by its nature, network or the disk. The way the errors 
handled determines will the app survive if image cannot be read (for any 
reason including wrong or absent location). For example, all browses do 
not fail in the case just show placeholders instead of images. And that 
approach has been chosen in for image fetching in JDK initially. 
Alexander's fix just restores the status quo.
I agree that the spec could be more explicit on that. Maybe it is 
reasonable to create a separate issue for that because it is more than a 
regression fix and requires some research to clarify the used approach. 
Probably the SM scenario is not coherent with it.

--Semyon
>
> -phil.
>
> On 04/15/2016 12:17 PM, Semyon Sadetsky wrote:
>> URL addresses are often taken from resources which may be unavailable 
>> for some reason. The question is what should we do with the app in 
>> this case: let it survive without showing the image (in the same way 
>> if the URL is unavailable) or let it die gracefully according to the 
>> specs.
>> The second choice is not obvious.
>>
>> --Semyon
>>
>> On 4/15/2016 10:04 PM, Sergey Bylokhov wrote:
>>> On 15.04.16 21:54, Sergey Bylokhov wrote:
>>>> Also please take a look to the similar bug
>>>> https://bugs.openjdk.java.net/browse/JDK-4358053
>>>
>>> As usual I suggest to fail fast, and throw NPE. in Toolkit class and 
>>> in ImageIcon, probably in some other places. The reason is that we 
>>> already do that and I doubt that we can remove NPE when SecManager 
>>> is installed.
>>>
>>>>
>>>>>
>>>>>   Thanks,
>>>>>   Alexandr.
>>>>>
>>>>>>
>>>>>> -phil.
>>>>>>
>>>>>>
>>>>>> On 04/15/2016 11:10 AM, Alexander Scherbatiy wrote:
>>>>>>> On 15/04/16 20:30, Sergey Bylokhov wrote:
>>>>>>>> How the object of URLImageSource(null) will be useful? I guess we
>>>>>>>> will get some unspecified NPE exceptions if will try to call its
>>>>>>>> methods?
>>>>>>>   I know nothing about the URLImageSource(null) usefulness but
>>>>>>> ImageFetcher swallows the NPE during the image loading in the
>>>>>>> fetchloop() method:
>>>>>>> -------
>>>>>>>             try {
>>>>>>>                 src.doFetch();
>>>>>>>             } catch (Exception e) {
>>>>>>>                 System.err.println("Uncaught error fetching 
>>>>>>> image:");
>>>>>>>                 e.printStackTrace();
>>>>>>>             }
>>>>>>> -------
>>>>>>>
>>>>>>>   Thanks,
>>>>>>>   Alexandr.
>>>>>>>>
>>>>>>>> On 15.04.16 18:02, Alexander Scherbatiy wrote:
>>>>>>>>>
>>>>>>>>> Hello,
>>>>>>>>>
>>>>>>>>> Could you review the fix:
>>>>>>>>>    bug: https://bugs.openjdk.java.net/browse/JDK-8132706
>>>>>>>>>    webrev: http://cr.openjdk.java.net/~alexsch/8132706/webrev.00
>>>>>>>>>
>>>>>>>>>    The fix makes the Toolkit.getDefaultToolkit().getImage(URL)
>>>>>>>>> return a
>>>>>>>>> ToolkitImage based on URLImageSource with null url as it was 
>>>>>>>>> before
>>>>>>>>> the
>>>>>>>>> fix JDK-8011059.
>>>>>>>>>
>>>>>>>>>    Thanks,
>>>>>>>>>    Alexandr.
>>>>>>>>
>>>>>>>>
>>>>>>>
>>>>>>
>>>>>
>>>>
>>>>
>>>
>>>
>>
>



More information about the awt-dev mailing list