On Wed, 24 Jun 2026 03:28:52 GMT, Prasanta Sadhukhan <[email protected]> 
wrote:

> Swing UI classes are generally not thread-safe, yes. But 
> `javax.swing.text.html.parser.DTD` is not really a UI component; it is parser 
> infrastructure with shared mutable caches/maps. If the JDK parser can be 
> reached by parallel parsing code, then this is a real data-race bug: 
> Hashtable/Vector being individually synchronized gives a misleading partial 
> safety, while the compound operation is not atomic
> 
> Agreed, DTD as a whole is not thread-safe. This change is not intended to 
> make the entire class thread-safe.

If the `DTD` class is not thread-safe, it's unsafe to use it from different 
threads—it will produce different results based on timing between the threads 
and APIs these threads call. The end result may be not catastrophic, 
nevertheless the `DTD` object will end up in an inconsistent state.

> I think this should be closed as not an issue or don't fix.
> We aren't going to go and make this class thread safe now when it was never 
> promised.

Agreed.

I should've been clearer… I implied that the fix was unnecessary, and the bug 
should be closed as _Won't Fix_ (unless we intend to make the `DTD` class 
thread-safe).

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

PR Comment: https://git.openjdk.org/jdk/pull/31568#issuecomment-4787666398

Reply via email to