# tornadofx


08/23/2018, 2:02 PM
#1146 Association is not thread-safe when lazily initializing cascadeOptions [grails/grails-data-mapping] Issue created by longwa Per discussion on Slack, this method is not thread-safe and can result in an
if multiple threads cascade validation at the same time for the same entity. In this case, the following error will occur:
Copy code
Caused by: java.lang.UnsupportedOperationException: null
        at java.util.Collections$UnmodifiableCollection.add(
        at org.grails.datastore.mapping.model.types.Association.buildCascadeOperations(
        at org.grails.datastore.mapping.model.types.Association.getCascadeOperations(
        at org.grails.datastore.mapping.model.types.Association.doesCascade(
        at grails.gorm.validation.PersistentEntityValidator.cascadeToAssociativeProperty(PersistentEntityValidator.groovy:134)
        at grails.gorm.validation.PersistentEntityValidator.validate(PersistentEntityValidator.groovy:82)
        at org.grails.datastore.gorm.GormEntity$Trait$
        at org.grails.datastore.gorm.GormEntity$Trait$Helper$save$ Source)
Any state on the
needs to be thread-safe since the same validator instance is used for entities of the same type. In this case, there are a few options: 1. Make the
synchronized which would fix the problem (although it does still allow multiple initializations of the options, in this case it would be fine). 2. Per @jameskleeh making the line below a local variable would also fix the issue. 1. Another option (not discussed in slack) is why this is even lazily initialized in the first place. Why not just call it in the constructor so the object fully constructed before it can be used. It doesn't seem like it would be that expensive unless there's some catch-22 where the
can't be used until the Association is built or something along those lines. I assume there's some reason why the
are lazily initialized to begin with, but worth throwing out there. Environment Grails 3.3.8 GORM 6.1.11.BUILD-SNAPSHOT Oracle jdk1.8.0_181


08/23/2018, 2:02 PM
TornadoFX workshop was a blast! Thank you @carlw for sending those keycaps and thank you all for the support and patience. I am hoping we will see newcomers on here soon!