Skip to content

KotlinBeanInfoFactory doesn't consider get-prefixed methods as getters for boolean properties #3249

Closed
@mmrsic

Description

@mmrsic

This is a follow-up to spring-projects/spring-data-jpa#3771

When using a Boolean property without "is" prefix, an exception "Invoked method is not a property accessor" is raised in version 3.3.8 whereas no exception is raised in version 3.2.8.

Kindly check out the extended test case showing two Boolean variants: https://github.com/mmrsic/spring-boot-data-329-issue/blob/main/src/test/kotlin/org/springboot/issues/springbootdata329issue/ApplicationTests.kt

The test case works in 3.2.8 but fails in 3.3.8 and 3.2.9-12.

  @Test
    fun testInvokedMethodIsNotAPropertyAccessorSpringBoot329() {
        val childId = "childId"
        val child = SpringBootTestChildEntity(childId)
        val parent = SpringBootTestParentEntity(parentId = "parentId", children = mutableListOf(child))
        repo.save(parent)

        // act
        val result = repo.findByChildrenChildId(childId)

        // assert
        assert(result.isNotEmpty())
        result.forEach {
            val children = it.children
            children.childId // This fails with IllegalStateException for Spring Boot 3.2.9 but works in 3.3.8
            children.isChild
            children.fromOuterSpace // This fails in Spring Boot 3.3.8 (because of missing "is" prefix) but works in 3.2.8
        }
    }

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions