On Wed, 6 Aug 2025 22:25:37 GMT, Phil Race <p...@openjdk.org> wrote:

>> src/java.desktop/share/classes/javax/imageio/stream/FileCacheImageOutputStream.java
>>  line 249:
>> 
>>> 247:             }
>>> 248:             try {
>>> 249:                 cache.close();
>> 
>> I notice a similar nested class/method in FileCacheImageInputStream with a 
>> few differences. Does the cache.close() and cacheFile.delete need to be 
>> wrapped in null checks? And once deleted do the StreamDisposerRecord 
>> pointers (this.cacheFile and this.cache) need to be set to null like in the 
>> ImageInputStream version of the code?
>
> Yes, I could re-use that. I just need to make it accessible .. but not public.
> That one has null checks because it clears the vars. 
> My version uses a "disposed" var for the same since I made those vars final.

Use of `final` is recommended wherever possible, as the values are then 
guaranteed to be visible on other threads (e.g. the disposer thread).

However IIUC, values set in a `DisposerRecord` by a program thread should 
(already) be visible on the disposer thread because `Disposer.add()` and 
`Disposer.run()` (via `records.put()` and `records.remove()`, respectively) 
lock the same `records` `Hashtable` object.

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

PR Review Comment: https://git.openjdk.org/jdk/pull/26650#discussion_r2258574384

Reply via email to