Skip to content

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

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Closed
mmrsic opened this issue Feb 18, 2025 · 2 comments
Assignees
Labels
in: kotlin Kotlin support type: bug A general bug

Comments

@mmrsic
Copy link

mmrsic commented Feb 18, 2025

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
        }
    }
@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Feb 18, 2025
@christophstrobl christophstrobl added the in: kotlin Kotlin support label Feb 19, 2025
@mp911de mp911de transferred this issue from spring-projects/spring-data-jpa Feb 20, 2025
@mp911de mp911de changed the title Switching from 3.2.8 to 3.3.8 causes exception for Bean property with "is" prefix KotlinBeanInfoFactory doesn't consider get-prefixed methods as getters for boolean properties Feb 20, 2025
@mp911de mp911de added type: bug A general bug and removed status: waiting-for-triage An issue we've not yet triaged labels Feb 20, 2025
@mp911de mp911de added this to the 3.3.11 (2024.0.11) milestone Feb 20, 2025
mp911de added a commit that referenced this issue Feb 20, 2025
We now additionally consider get-prefixed methods in addition to is-prefixed methods as getters for boolean properties.

Closes #3249
mp911de added a commit that referenced this issue Feb 20, 2025
We now additionally consider get-prefixed methods in addition to is-prefixed methods as getters for boolean properties.

Closes #3249
@mp911de
Copy link
Member

mp911de commented Feb 20, 2025

That's fixed now and snapshots will be deployed into repo.spring.io in a few moments. Care to upgrade to the 3.3.10-SNAPSHOT and verify whether the fix is working for you?

@mmrsic
Copy link
Author

mmrsic commented Mar 31, 2025

I can confirm that the issue is fixed with release 3.3.10.

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
in: kotlin Kotlin support type: bug A general bug
Projects
None yet
Development

No branches or pull requests

4 participants