Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

2.15.0 changed the result of serialization of functions returning boolean #670

Closed
PoisonedYouth opened this issue May 2, 2023 · 5 comments
Labels

Comments

@PoisonedYouth
Copy link

Describe the bug
The result in serialization of a function returning a boolean is changed from version 2.14.2 and 2.15.0.

To Reproduce
2.14.2

interface TestInterface{
        fun isValid(): Boolean
    }

    class TestClass: TestInterface{
        override fun isValid(): Boolean {
            return true
        }
    }

    @Test
    fun `serialize`(){
        val test = TestClass()

        val actual = jacksonObjectMapper().writeValueAsString(test)

        assertThat(actual).isEqualTo("{\"valid\":true}")
    }

2.15.0

interface TestInterface{
        fun isValid(): Boolean
    }

    class TestClass: TestInterface{
        override fun isValid(): Boolean {
            return true
        }
    }

    @Test
    fun `serialize`(){
        val test = TestClass()

        val actual = jacksonObjectMapper().writeValueAsString(test)

        assertThat(actual).isEqualTo("{\"isValid\":true}")
    }

Expected behavior
The serialization of functions does not change.

Versions
Kotlin: 1.8.20
Jackson-module-kotlin: 2.15.2
Jackson-databind: SpringBoot: 3.0.6 (brings jackson-databind 2.14.2)

Additional context
Add any other context about the problem here.

@k163377
Copy link
Contributor

k163377 commented May 3, 2023

This is a destructive change caused by #641.

There were certainly undesirable aspects to this change.
However, I believe the overall benefit would be greater if this behavior were left as is.

The reasons are as follows

  • Difficulty in fixing this problem without causing recurrence of problems like Regression on data binding in 2.11.0 with specific field naming #340 .
    • Need to determine if java-getter is a property or getter-like in Kotlin.
      • Complex processing is required to achieve this, which also increases the load on serialization.
  • Defining it as a property instead of getter-like avoids the problem.

Unless we get a lot of requests or find a better fix, I would like to hold off on fixing this issue.

@PoisonedYouth
Copy link
Author

PoisonedYouth commented May 3, 2023

For me it breaks the serialization of one of my projects. I didn't expect the change according to the release notes / migration guide. Or did I overlook something?

Generally I don't have problems with this change, it's just it's unexpected behavior for me.

@k163377
Copy link
Contributor

k163377 commented May 4, 2023

I didn't expect the change according to the release notes / migration guide.

Yes, we did not detect that such regression was occurring.
A reference to this issue will be added in the future.

k163377 added a commit to k163377/jackson-module-kotlin that referenced this issue May 4, 2023
@PoisonedYouth
Copy link
Author

Thank you very much.

k163377 added a commit that referenced this issue May 5, 2023
k163377 added a commit that referenced this issue May 5, 2023
@pjfanning
Copy link
Member

@k163377 can this be closed due to https://github.com/FasterXML/jackson-module-kotlin/blob/2.16/release-notes/VERSION-2.x#L25-L27 ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants