Skip to content

Add reproducer for Optional getter with String property to serde-jackson-tck#1237

Draft
graemerocher with Copilot wants to merge 4 commits into
2.16.xfrom
copilot/add-reproducer-to-serde-jackson-tck
Draft

Add reproducer for Optional getter with String property to serde-jackson-tck#1237
graemerocher with Copilot wants to merge 4 commits into
2.16.xfrom
copilot/add-reproducer-to-serde-jackson-tck

Conversation

Copilot AI commented Jan 16, 2026

Copy link
Copy Markdown
Contributor

Adds a TCK test case for serialization/deserialization of a class where the getter returns Optional<String> but the field and setter use plain String.

Changes

  • serde-jackson-tck/src/main/java/io/micronaut/serde/jackson/optionalwrap/MyThing.java - Test class demonstrating the pattern
  • serde-jackson-tck/src/main/groovy/io/micronaut/serde/jackson/OptionalGetterSpec.groovy - Abstract spec with round-trip and deserialization tests
  • test-suite-tck-jackson-databind/.../DatabindOptionalGetterSpec.groovy - Concrete implementation for Jackson Databind (passes)
  • test-suite-tck-serde/.../SerdeOptionalGetterSpec.groovy - Concrete implementation for pure Serde (marked @Ignore as reproducer - demonstrates the issue)

Test case

@Serdeable
public class MyThing {
    private String value;

    public Optional<String> getValue() {
        return Optional.ofNullable(value);
    }

    public void setValue(String value) {
        this.value = value;
    }
}

Test behavior

  • Jackson Databind: Tests pass - handles the Optional getter pattern correctly
  • Pure Serde: Tests fail (marked @Ignore) - demonstrates the issue that needs fixing
Original prompt

add a reproducer for the following code to serde-jackson-tck creating a PR targetting the 2.16.x branch

@MicronautTest
public class DemoSerdeTest {

@Inject ObjectMapper objectMapper;

@test
void test() throws Exception {
MyThing myThing = new MyThing();
myThing.setValue("someValue");
String json = objectMapper.writeValueAsString(myThing);
MyThing other = objectMapper.readValue(json, MyThing.class);
Assertions.assertEquals(myThing.value, other.value);
}

@test
void test2() throws Exception {
String json =
"""
{"value":"myOtherValue"}
""";
MyThing other = objectMapper.readValue(json, MyThing.class);
Assertions.assertEquals("myOtherValue", other.value);
}

@Serdeable
public static class MyThing {
private String value;

public Optional<String> getValue() {
  return Optional.ofNullable(value);
}

public void setValue(String value) {
  this.value = value;
}

}
}


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

@cla-assistant

cla-assistant Bot commented Jan 16, 2026

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

Co-authored-by: graemerocher <66626+graemerocher@users.noreply.github.com>
Copilot AI changed the title [WIP] Add reproducer for DemoSerdeTest in serde-jackson-tck Add reproducer for Optional getter with String property to serde-jackson-tck Jan 16, 2026
Copilot AI requested a review from graemerocher January 16, 2026 16:17

import io.micronaut.serde.jackson.OptionalGetterSpec

class DatabindOptionalGetterSpec extends OptionalGetterSpec {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

also add the equivalent test to test-suite-tck-serde

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added equivalent test in commit 55a2062. The test is marked with @Ignore as it fails in pure Serde (demonstrating the issue), while passing in Jackson Databind.

Co-authored-by: graemerocher <66626+graemerocher@users.noreply.github.com>

Copilot AI commented Jan 16, 2026

Copy link
Copy Markdown
Contributor Author

Just as a heads up, I was blocked by some firewall rules while working on your feedback. Expand below for details.

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • ge.micronaut.io
    • Triggering command: /usr/lib/jvm/temurin-17-jdk-amd64/bin/java /usr/lib/jvm/temurin-17-jdk-amd64/bin/java --add-opens=java.base/java.lang=ALL-UNNAMED --add-opens=java.base/java.lang.invoke=ALL-UNNAMED --add-opens=java.base/java.util=ALL-UNNAMED --add-opens=java.prefs/java.util.prefs=ALL-UNNAMED --add-exports=jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED --add-exports=jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED --add-opens=java.base/java.util=ALL-UNNAMED --add-opens=java.prefs/java.util.prefs=ALL-UNNAMED --add-opens=java.base/java.nio.charset=ALL-UNNAMED --add-opens=java.base/java.net=ALL-UNNAMED --add-opens=java.base/java.util.concurrent.atomic=ALL-UNNAMED --add-opens=java.xml/javax.xml.namespace=ALL-UNNAMED -XX:MaxMetaspaceSize=1g -Dfile.encoding=UTF-8 -Duser.country -Duser.language=en -Duser.variant -cp /home/REDACTED/.gradle/wrapper/dists/gradle-8.14.3-bin/cv11ve7ro1n3o1j4so8xd9n66/gradle-8.14.3/lib/gradle-daemon-main-8.14.3.jar (dns block)
  • google.com
    • Triggering command: /usr/lib/jvm/temurin-17-jdk-amd64/bin/java /usr/lib/jvm/temurin-17-jdk-amd64/bin/java -Dorg.gradle.internal.worker.tmpdir=/home/REDACTED/work/micronaut-serialization/micronaut-serialization/test-suite-tck-serde/build/tmp/test/work @/home/REDACTED/.gradle/.tmp/gradle-worker-classpath14276590821709945582txt -Xmx512m -Dfile.encoding=UTF-8 -Duser.country -Duser.language=en -Duser.variant -ea worker.org.gradle.process.internal.worker.GradleWorkerMain &#39;Gradle Test Executor 8&#39; (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

@sonarqubecloud

Copy link
Copy Markdown

Quality Gate Failed Quality Gate failed

Failed conditions
0.0% Coverage on New Code (required ≥ 70%)

See analysis details on SonarQube Cloud

@graemerocher graemerocher added the type: bug Something isn't working label Jan 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

type: bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants