[1.4.1] POJO beans with chained/fluent setters fail to serialize

Open
#548 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
65/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Active
Tech stack
java
Domain
backend

Research direction

Start at BeanPropertyType and trace how the TypeInformation and DefaultMapper handle the getters and setters shown in the reproducing example. Reproduce the issue with the chained CustomConfigProperty bean and verify that fluent setters are recognized and YAML serialization and loading preserve the bean properties.

Written by the indexing model from the issue text.

Description

Context

Version: 1.4.1
JDK: 8

When defining configuration POJO beans mapped by ConfigMe's BeanPropertyType, using fluent setter methods (such as those generated by Lombok's @Accessors(chain = true) or custom return this; setters) breaks the JavaBean property introspection.

Reproducing Example

Consider a simplified configuration bean:

import lombok.*;
import lombok.experimental.Accessors;

@Getter
@Setter
@Accessors(chain = true)
@NoArgsConstructor(access = AccessLevel.PUBLIC)
public class CustomConfigProperty {

    private boolean enabled = true;
    private String fileName = "";
    private int weight = 1;
    private int minHeight = 0;
    private int maxHeight = 255;
}

When registering and saving this bean via ConfigMe:

public static final Property<CustomConfigProperty[]> PROPERTIES =
    new PropertyBuilder.ArrayPropertyBuilder<>(
        new BeanPropertyType<>(new TypeInformation(CustomConfigProperty.class), DefaultMapper.getInstance()),
        CustomConfigProperty[]::new)
        .path("custom.properties")
        .defaultValue(new CustomConfigProperty[0])
        .build();
Expected Behavior

ConfigMe should map the bean's fields to YAML properties based on getters and setters.

Actual Behavior

ConfigMe does not recognize the fluent setters, resulting in empty YAML outputs or unpopulated instances when reading from configuration files.

Thank you ❤️

Dominant language
Java
Stars
44
Forks
21
Avg merge
2d 2h
Merged PRs (30d)
3

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from AuthMe/ConfigMe

All issues in AuthMe/ConfigMe

Similar issues

More Java issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.