[
https://issues.apache.org/jira/browse/VALIDATOR-427?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Sebb resolved VALIDATOR-427.
----------------------------
Resolution: Not A Bug
Please raise a new issue for potential enhancements to the class.
The current class works as designed if it is used as documented.
> Race Condition in DomainValidator
> ---------------------------------
>
> Key: VALIDATOR-427
> URL: https://issues.apache.org/jira/browse/VALIDATOR-427
> Project: Commons Validator
> Issue Type: Bug
> Affects Versions: 1.6
> Reporter: Steven Sheehy
>
> There's a race condition in DomainValidator which causes our application to
> fail sometimes. The issue occurs when the DomainValidator.getInstance() is
> called before we can call DomainValidator.updateTLDOverride() and we receive
> a IllegalStateException("Can only invoke this method before calling
> getInstance"). In a multi-threaded environment, DomainValidator.getInstance()
> can be called at any time and it is difficult to find a location in
> application startup which ensures DomainValidator.updateTLDOverride() is
> called before to initialize it. I was able to workaround during application
> runtime it by placing the initialization in a Spring @Configuration class,
> but there is no proper location in JUnit tests which can be called before any
> tests run.
> Therefore, I think the proper approach to address this is to allow
> DomainValidator.updateTLDOverride() to be updated at any time including after
> calls to getInstance(). Examining the source, I see that the both methods are
> synchronized and that the custom TLD arrays are all volatile. Therefore,
> assuming Java 1.5 or greater and its guarantees about volatile assignments,
> the code already guarantees proper synchronization for the TLD plus arrays
> and the inUse flag is not needed and can be removed.
--
This message was sent by Atlassian JIRA
(v6.3.15#6346)