Skip to content

wrong handling of bean properties in Records #718

Description

@struberg

Describe the bug
The spec requires to serialise attributs as "bean properties" according to the Java Bean 1.1 specification.
This seems not to be done in Records

I extended the RecordTest to have an additional bean attribute method as below

public record CarWithExtraMethod(String type, String color) {

    public String type() {
        return type;
    }

    public String name() {
        return color + " " + type;
    }

    public String getOtherName() {
        return color + " " + type;
    }

}

As result I get the following JSON: {"color":"green","getOtherName":"green skoda","type":"skoda"}.

This is imo wrong as the attribute name should only be otherName and not getOtherName.
Note that the method name() gets skipped as it is not a bean attribute (no getXxx nor isXxxx).

To Reproduce
Steps to reproduce the bug

Expected behavior
The resulting JSON should be {"color":"green","otherName":"green skoda","type":"skoda"}

System information:

  • OS: OSX
  • Java Version: 17
  • Yasson Version: latest from today

Metadata

Metadata

Assignees

Labels

bugSomething isn't working right

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions