Skip to content

Commit

Permalink
Update DirtyCheckingSupport
Browse files Browse the repository at this point in the history
Initialize DIRTY_CLASS_MARKER as Immutable collection, as marker should not be modified
Fixes #1462

Signed-off-by: Puneet Behl <[email protected]>
  • Loading branch information
puneetbehl committed Jul 27, 2021
1 parent 213ea64 commit f7ae81a
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,9 @@ trait DirtyCheckable {
*/
void markDirty(String propertyName) {
if( $changedProperties != null && !$changedProperties.containsKey(propertyName)) {
if (DirtyCheckingSupport.DIRTY_CLASS_MARKER.is($changedProperties)) {
trackChanges()
}
$changedProperties.put propertyName, ((GroovyObject)this).getProperty(propertyName)
}
}
Expand Down Expand Up @@ -113,6 +116,9 @@ trait DirtyCheckable {
if ((isNull && oldValue != null) ||
(!isNull && oldValue == null) ||
(!isNull && !newValue.equals(oldValue))) {
if (DirtyCheckingSupport.DIRTY_CLASS_MARKER.is($changedProperties)) {
trackChanges()
}
$changedProperties.put propertyName, oldValue
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ class DirtyCheckingSupport {
/**
* Used internally as a marker. Do not use in user code
*/
public static final Map DIRTY_CLASS_MARKER = [:]
public static final Map DIRTY_CLASS_MARKER = [:].asImmutable()
/**
* Checks whether associations are dirty
*
Expand Down

0 comments on commit f7ae81a

Please sign in to comment.