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

class deserialization behaviour changes when to 2.10.1+ #317

Closed
kelvinc1024 opened this issue Apr 3, 2020 · 2 comments
Closed

class deserialization behaviour changes when to 2.10.1+ #317

kelvinc1024 opened this issue Apr 3, 2020 · 2 comments

Comments

@kelvinc1024
Copy link

compile "com.fasterxml.jackson.module:jackson-module-kotlin:2.9.9"

change to

compile "com.fasterxml.jackson.module:jackson-module-kotlin:2.10.1"

cause following test code was that originally AC become error

Expected: fieldA
     but none found
 ; 
Unexpected: isFieldA

java.lang.AssertionError: 
Expected: fieldA
     but none found
 ; 
Unexpected: isFieldA
import com.fasterxml.jackson.databind.ObjectMapper
import com.fasterxml.jackson.module.kotlin.registerKotlinModule
import org.junit.Test
import org.skyscreamer.jsonassert.JSONAssert

class JsonSerializeDeserializeTest() {

    val objectMapper: ObjectMapper

    init {
        objectMapper = ObjectMapper().registerKotlinModule()
    }

    @Test
    fun jsonSeserializeTestSubjectA() {
        JSONAssert.assertEquals(
            """
                    {
                        "fieldA" : true,
                        "fieldB" : true,
                        "fieldC" : "hola mundo"
                    }
                """.trimIndent(),
            objectMapper.writeValueAsString(TestSubjectA(true, true, "hola mundo")),
            true
        )
    }

    @Test
    fun jsonSeserializeTestSubjectB() {
        JSONAssert.assertEquals(
            """
                    {
                        "fieldA" : true,
                        "fieldB" : true,
                        "fieldC" : "hola mundo"
                    }
                """.trimIndent(),
            objectMapper.writeValueAsString(TestSubjectB(true, true, "hola mundo")),
            true
        )
    }
}
import kotlin.Metadata;
import org.jetbrains.annotations.NotNull;

@Metadata(
        mv = {1, 1, 16},
        bv = {1, 0, 3},
        k = 1,
        d1 = {"\u0000\"\n\u0002\u0018\u0002\n\u0002\u0010\u0000\n\u0000\n\u0002\u0010\u000b\n\u0002\b\u0002\n\u0002\u0010\u000e\n\u0002\b\f\n\u0002\u0010\b\n\u0002\b\u0002\b\u0087\b\u0018\u00002\u00020\u0001B\u001d\u0012\u0006\u0010\u0002\u001a\u00020\u0003\u0012\u0006\u0010\u0004\u001a\u00020\u0003\u0012\u0006\u0010\u0005\u001a\u00020\u0006¢\u0006\u0002\u0010\u0007J\t\u0010\f\u001a\u00020\u0003HÆ\u0003J\t\u0010\r\u001a\u00020\u0003HÆ\u0003J\t\u0010\u000e\u001a\u00020\u0006HÆ\u0003J'\u0010\u000f\u001a\u00020\u00002\b\b\u0002\u0010\u0002\u001a\u00020\u00032\b\b\u0002\u0010\u0004\u001a\u00020\u00032\b\b\u0002\u0010\u0005\u001a\u00020\u0006HÆ\u0001J\u0013\u0010\u0010\u001a\u00020\u00032\b\u0010\u0011\u001a\u0004\u0018\u00010\u0001HÖ\u0003J\t\u0010\u0012\u001a\u00020\u0013HÖ\u0001J\t\u0010\u0014\u001a\u00020\u0006HÖ\u0001R\u0011\u0010\u0004\u001a\u00020\u0003¢\u0006\b\n\u0000\u001a\u0004\b\b\u0010\tR\u0011\u0010\u0005\u001a\u00020\u0006¢\u0006\b\n\u0000\u001a\u0004\b\n\u0010\u000bR\u0011\u0010\u0002\u001a\u00020\u0003¢\u0006\b\n\u0000\u001a\u0004\b\u0002\u0010\t¨\u0006\u0015"},
        d2 = {"Ljp/paypay/clmapi/integration/helper/TestSubjectB;", "", "isFieldA", "", "fieldB", "fieldC", "", "(ZZLjava/lang/String;)V", "getFieldB", "()Z", "getFieldC", "()Ljava/lang/String;", "component1", "component2", "component3", "copy", "equals", "other", "hashCode", "", "toString", "clm-api.test"}
)
public final class TestSubjectA {
    private final boolean isFieldA;
    private final boolean fieldB;
    @NotNull
    private final String fieldC;

    public final boolean isFieldA() {
        return this.isFieldA;
    }

    public final boolean getFieldB() {
        return this.fieldB;
    }

    @NotNull
    public final String getFieldC() {
        return this.fieldC;
    }

    public TestSubjectA(boolean isFieldA, boolean fieldB, @NotNull String fieldC) {
        super();
        this.isFieldA = isFieldA;
        this.fieldB = fieldB;
        this.fieldC = fieldC;
    }
}
data class TestSubjectB(
    val isFieldA: Boolean,
    val fieldB: Boolean,
    val fieldC: String
)

build.gradle

plugins {
    id 'java'
    id 'org.jetbrains.kotlin.jvm' version '1.3.60'
}

group 'org.example'
version '1.0-SNAPSHOT'

sourceCompatibility = 1.8

repositories {
    mavenCentral()
}

dependencies {
    implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8"
    compile 'com.fasterxml.jackson.core:jackson-core:2.10.1'
    compile 'com.fasterxml.jackson.core:jackson-annotations:2.10.1'
    compile 'com.fasterxml.jackson.core:jackson-databind:2.10.1'
//    compile "com.fasterxml.jackson.module:jackson-module-kotlin:2.9.9"
    compile "com.fasterxml.jackson.module:jackson-module-kotlin:2.10.1"
    testCompile group: 'junit', name: 'junit', version: '4.12'
    testCompile group: 'org.skyscreamer', name: 'jsonassert', version: '1.5.0'
}

compileKotlin {
    kotlinOptions.jvmTarget = "1.8"
}
compileTestKotlin {
    kotlinOptions.jvmTarget = "1.8"
}
@kelvinc1024 kelvinc1024 changed the title class deserialization behaviour changes when upgrade 2.9.9 -> 2.10.x class deserialization behaviour changes when to 2.10.1+ Apr 3, 2020
@kelvinc1024
Copy link
Author

not sure that is the expected behaviour or not
I saw the related ticket as well, but in reverse
#80

@k163377
Copy link
Contributor

k163377 commented Feb 18, 2023

It is considered resolved and closed.

@k163377 k163377 closed this as completed Feb 18, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants