File tree Expand file tree Collapse file tree 8 files changed +80
-3
lines changed
main/groovy/grails/databinding
test/groovy/grails/databinding
grails-web-url-mappings/src/test/groovy/org/grails/web/mapping Expand file tree Collapse file tree 8 files changed +80
-3
lines changed Original file line number Diff line number Diff line change 1- name-template : $NEXT_PATCH_VERSION
2- tag-template : v$NEXT_PATCH_VERSION
1+ name-template : $RESOLVED_VERSION
2+ tag-template : v$RESOLVED_VERSION
33version-resolver :
44 major :
55 labels :
Original file line number Diff line number Diff line change 1010 - master
1111 - ' [4-9]+.[0-9]+.x'
1212 - ' [3-9]+.[3-9]+.x'
13+ workflow_dispatch :
1314jobs :
1415 build :
1516 runs-on : ubuntu-latest
Original file line number Diff line number Diff line change @@ -13,6 +13,7 @@ buildscript {
1313 classpath " javax.xml.bind:jaxb-api:$jaxbVersion "
1414 classpath " com.sun.xml.bind:jaxb-impl:$jaxbVersion "
1515 classpath " org.codehaus.groovy.modules.http-builder:http-builder:0.7.2"
16+ classpath " org.gradle:test-retry-gradle-plugin:1.3.1"
1617 }
1718}
1819
@@ -340,6 +341,7 @@ subprojects { project ->
340341 apply plugin : ' idea'
341342 apply plugin : ' project-report'
342343 apply plugin : ' nebula.optional-base'
344+ apply plugin : " org.gradle.test-retry"
343345
344346 if (! isTestSuite) {
345347
@@ -502,6 +504,11 @@ subprojects { project ->
502504 }
503505
504506 test {
507+ retry {
508+ maxRetries = 2
509+ maxFailures = 20
510+ failOnPassedAfterRetry = true
511+ }
505512 testLogging {
506513 events " passed" , " skipped" , " failed"
507514
Original file line number Diff line number Diff line change @@ -32,6 +32,7 @@ import org.grails.databinding.xml.GPathResultMap
3232import java.lang.annotation.Annotation
3333import java.lang.reflect.Array
3434import java.lang.reflect.Field
35+ import java.lang.reflect.Modifier
3536import java.lang.reflect.ParameterizedType
3637
3738/**
@@ -622,6 +623,9 @@ class SimpleDataBinder implements DataBinder {
622623 if (metaProperty instanceof MetaBeanProperty ) {
623624 def mbp = (MetaBeanProperty )metaProperty
624625 propertyType = mbp. getter?. returnType ?: mbp. field?. type
626+ if (propertyType && (propertyType. interface || Modifier . isAbstract(propertyType. modifiers))) {
627+ propertyType = mbp. field?. type
628+ }
625629 propertyGetter = mbp. getter
626630 }
627631 if (propertyType == null || propertyType == Object ) {
Original file line number Diff line number Diff line change @@ -612,6 +612,38 @@ class SimpleDataBinderSpec extends Specification {
612612 comment. attachments. find { it. filename == ' foo.txt' }
613613 comment. attachments. find { it. filename == ' bar.txt' }
614614 }
615+
616+ @Issue (' https://github.com/grails/grails-core/issues/12150' )
617+ void ' Test binding when class and embedded classes both implements an interface' () {
618+ given :
619+ SimpleDataBinder binder = new SimpleDataBinder ()
620+
621+ and :
622+ SimpleMapDataBindingSource input = [a : [data : ' abc' ]] as SimpleMapDataBindingSource
623+ ClassB classWithInterface = new ClassB ()
624+
625+ when :
626+ binder. bind(classWithInterface, input)
627+
628+ then :
629+ classWithInterface. a. data == ' abc'
630+ }
631+
632+ @Issue (' https://github.com/grails/grails-core/issues/12150' )
633+ void ' Test binding when class and embedded classes extends abstract class and implements an interface' () {
634+ given :
635+ SimpleDataBinder binder = new SimpleDataBinder ()
636+
637+ and :
638+ SimpleMapDataBindingSource input = [a : [data : ' abc' ]] as SimpleMapDataBindingSource
639+ FromAbstractB fromAbstractB = new FromAbstractB ()
640+
641+ when :
642+ binder. bind(fromAbstractB, input)
643+
644+ then :
645+ fromAbstractB. a. data == ' abc'
646+ }
615647}
616648
617649class Factory {
@@ -688,3 +720,26 @@ class Attachment {
688720 String filename
689721}
690722
723+ interface InterfaceA {
724+ String getData ()
725+ }
726+
727+ interface InterfaceB {
728+ InterfaceA getA ()
729+ }
730+
731+ class ClassA implements InterfaceA {
732+ String data
733+ }
734+
735+ class ClassB implements InterfaceB {
736+ ClassA a
737+ }
738+
739+ class AbstractB {
740+ ClassA a
741+ }
742+
743+ class FromAbstractB extends AbstractB {
744+
745+ }
Original file line number Diff line number Diff line change @@ -37,7 +37,7 @@ dependencies {
3737 }
3838
3939 testImplementation " net.sf.expectit:expectit-core:0.9.0"
40- testImplementation " com.github.jnr:jnr-posix:3.1.10 "
40+ testImplementation " com.github.jnr:jnr-posix:3.1.11 "
4141
4242 runtimeOnly " org.slf4j:slf4j-simple:$slf4jVersion "
4343 runtimeOnly " org.codehaus.plexus:plexus-component-api:1.0-alpha-33"
Original file line number Diff line number Diff line change @@ -9,11 +9,16 @@ import org.grails.support.MockApplicationContext
99import org.grails.web.mapping.DefaultLinkGenerator
1010import org.grails.web.mapping.DefaultUrlMappingEvaluator
1111import org.grails.web.mapping.DefaultUrlMappingsHolder
12+ import org.grails.web.util.WebUtils
1213import spock.lang.Issue
1314import spock.lang.Specification
1415
1516class RestfulUrlMappingSpec extends Specification {
1617
18+ def setup () {
19+ WebUtils . clearGrailsWebRequest()
20+ }
21+
1722 def mappings = {
1823 delete " /$controller /$id (.$format )?" (action : " delete" )
1924 get " /$controller (.$format )?" (action : " index" )
Original file line number Diff line number Diff line change @@ -10,6 +10,7 @@ import org.grails.support.MockApplicationContext
1010import org.grails.web.mapping.DefaultLinkGenerator
1111import org.grails.web.mapping.DefaultUrlMappingEvaluator
1212import org.grails.web.mapping.DefaultUrlMappingsHolder
13+ import org.grails.web.util.WebUtils
1314import org.springframework.mock.web.MockServletContext
1415import spock.lang.IgnoreIf
1516import spock.lang.Specification
@@ -20,6 +21,10 @@ import spock.lang.Specification
2021@IgnoreIf ({ env[' CI' ] })
2122class UrlMappingsWithHttpMethodSpec extends Specification {
2223
24+ def setup () {
25+ WebUtils . clearGrailsWebRequest()
26+ }
27+
2328 def mappings = {
2429 " /foo" ( controller :" bar" , action :" save" , method :" POST" )
2530 " /foo2" ( controller :" bar" , action :" save" , method :" PUT" )
You can’t perform that action at this time.
0 commit comments