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

Challenge: ee.jakarta.tck.json.bind.defaultmapping.polymorphictypes.AnnotationTypeInfoTest #347

Open
jeanouii opened this issue Oct 11, 2023 · 0 comments

Comments

@jeanouii
Copy link

Per the current TCK Process documentation, please find bellow a challenge related to JSON-B TCK. Can someone please add the challenge label which is required by the TCK Process but not available to everyone to add.

The relevant specification version and section number(s)

https://jakarta.ee/specifications/jsonb/3.0/jakarta-jsonb-spec-3.0.html#custom-instantiation

The coordinates of the challenged test(s)

Only following test in the class are related to the challenge

  • #testCreatorDeserialization

The exact TCK version

JSON-B TCK version 3.0.0

The implementation being tested, including name and company

Apache Johnzon 2.0.0-SNAPSHOT from the Apache Software Foundation

A full description of why the test is invalid and what the correct behavior is believed to be

The test aims at covering the polymorphic mapping using JsonbTypeInfo and JsonbSubtype which is fine. The DateConstructor, in its current form

    public static final class DateConstructor implements SomeDateType {

        public LocalDate localDate;

        @JsonbCreator
        public DateConstructor(@JsonbProperty("localDate") @JsonbDateFormat(value = "dd-MM-yyyy", locale = "nl-NL") LocalDate localDate) {
            this.localDate = localDate;
        }
    }

There is an ambiguity there in the way the localDate field should be deserialized. We have 2 candidates

  • the factory (constructor from DateConstruct)
  • the setter (direct field access which is public without a private setter)

The test implies that only one, the DateConstructor constructor and not the direct field.

In Johnzon we call first the factory and then the setters, because we see them as callback for the user to use after the object is constructed.

In this situation, the specification does not provide with a clear order. I'm going to create a issue to clarify this point but meanwhile, we need a challenge for this test.

I propose to create a PR in order to change the localDate modifier from public to private so there is no ambiguty anymore. We can add a public getter so we can even write an assert in the test using the deserialized value.

jeanouii added a commit to apache/johnzon that referenced this issue Oct 11, 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

1 participant