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

Unique comments repeated in MapProperty, ListProperty, ... #362

Closed
ljacqu opened this issue Aug 26, 2023 · 0 comments
Closed

Unique comments repeated in MapProperty, ListProperty, ... #362

ljacqu opened this issue Aug 26, 2023 · 0 comments
Labels
Milestone

Comments

@ljacqu
Copy link
Member

ljacqu commented Aug 26, 2023

Reported by Wector11211: if a comment is set on a bean that's used in a MapProperty, the comment is repeated even if it's defined to be unique:

public class ServerSettingHolder implements SettingsHolder {

    public static final Property<Map<String, ServerCollection>> SERVERS =
        new MapProperty<>("", 
          Map.of("foo", new ServerCollection(), "bar", new ServerCollection()),
          BeanPropertyType.of(ServerCollection.class));

}


public class ServerCollection {

    @Comment("Comment that is present on all instances")
    private List<String> servers = new ArrayList<>();

    public List<String> getServers() {
        return servers;
    }

    public void setServers(List<String> servers) {
        this.servers = servers;
    }
}

Problem

The mapper keeps a set of unique comments it's already used. The problem is when a bean type is used multiple times within the same property, it goes beyond the boundaries of the bean type. This not only affects MapProperty but any other collection properties where a bean property is used as type.

Solving this is a little tricky—I don't want to keep any global state, but there needs to be some mechanism to pass in a bit more state across multiple #toExportValue calls...

@ljacqu ljacqu added the bug label Aug 26, 2023
@ljacqu ljacqu added this to the 1.4.1 Release milestone Aug 26, 2023
ljacqu added a commit that referenced this issue Aug 27, 2023
- Add comment UUID to ValueWithComments
- Change SnakeYamlNodeBuilderImpl to only include comments once per UUID
@ljacqu ljacqu changed the title Comment on default value is repeated if it's not in a map Unique comments repeated in MapProperty, ListProperty, ... Aug 27, 2023
@ljacqu ljacqu closed this as completed Aug 27, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

No branches or pull requests

1 participant