Skip to content

Commit

Permalink
Merge pull request #339 from gpc/338-bundle-codes-transient-fields
Browse files Browse the repository at this point in the history
Fix #338, added unwrapIfProxy to BeanPropertyAccessorFactory is initialized
  • Loading branch information
sbglasius authored Feb 15, 2024
2 parents 27034ed + b19e7b2 commit 27f3212
Show file tree
Hide file tree
Showing 4 changed files with 373 additions and 330 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ class BeanPropertyAccessorFactory implements GrailsApplicationAware {
if (bean == null) {
new PropertyPathAccessor(propertyPath)
} else {
resolvePropertyFromPath(bean, propertyPath)
resolvePropertyFromPath(unwrapIfProxy(bean), propertyPath)
}
}

Expand Down Expand Up @@ -180,7 +180,11 @@ class BeanPropertyAccessorFactory implements GrailsApplicationAware {
}

private BeanWrapper beanWrapperFor(Class type, value) {
value ? PropertyAccessorFactory.forBeanPropertyAccess(proxyHandler.unwrapIfProxy(value)) : new BeanWrapperImpl(type)
value ? PropertyAccessorFactory.forBeanPropertyAccess(unwrapIfProxy(value)) : new BeanWrapperImpl(type)
}

private Object unwrapIfProxy(value) {
return proxyHandler.unwrapIfProxy(value)
}

private static final Pattern INDEXED_PROPERTY_PATTERN = ~/^(\w+)\[(.+)]$/
Expand All @@ -195,4 +199,6 @@ class BeanPropertyAccessorFactory implements GrailsApplicationAware {
def matcher = propertyName =~ INDEXED_PROPERTY_PATTERN
matcher.matches() ? (matcher[0] as String[])[1] : propertyName
}


}
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ import org.grails.datastore.mapping.model.PersistentEntity
import org.grails.datastore.mapping.model.PersistentProperty
import org.grails.scaffolding.model.property.Constrained
import org.grails.scaffolding.model.property.DomainProperty
import org.springframework.validation.Errors
import org.springframework.validation.FieldError

@CompileStatic
Expand Down
Loading

0 comments on commit 27f3212

Please sign in to comment.