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

Micronaut 4 regression: @EachProperty with enum-type @Parameter does not work #10944

Closed
eager-signal opened this issue Jul 3, 2024 · 0 comments
Assignees
Labels
type: bug Something isn't working type: regression A breaking change was introduced in a minor or patch release

Comments

@eager-signal
Copy link

Expected Behavior

In Micronaut 3, the following works:

// Configuration.java
@EachProperty("config")
public record Configuration(@Parameter MyEnum myEnum,
                            @NotEmpty List<@NotBlank String> cities) {

    public enum MyEnum {
        SUMMER,
        WINTER
    }
}

// ConfigurationTest.java
@MicronautTest
@Property(name ="config.summer.cities", value = "barcelona,atlanta,sydney")
@Property(name = "config.winter.cities", value = "albertville,lillehammer,nagano")
public class ConfigurationTest {

    @Inject
    private List<Configuration> configs;

    @Test
    void testEnumParameter() {
        assertEquals(2, configs.size());
        assertTrue(configs.contains(new Configuration(Configuration.MyEnum.SUMMER, List.of("barcelona", "atlanta", "sydney"))));
        assertTrue(configs.contains(new Configuration(Configuration.MyEnum.WINTER, List.of("albertville", "lillehammer", "nagano"))));
    }
}

Actual Behaviour

After upgrading to Micronaut 4, the test fails with:

io.micronaut.context.exceptions.BeanInstantiationException: Error instantiating bean of type  [com.example.Configuration]

Message: Missing bean argument value: myEnum
Path Taken: ConfigurationTest.configs --> new Configuration([MyEnum myEnum],List cities)

Steps To Reproduce

Run the above tests. The example project has a working main branch (Micronaut 3). The micronaut-4 branch illustrates the same code failing after the upgrade.

Environment Information

No response

Example Application

https://github.com/eager-signal/micronaut-parameter-bug

Version

4.5.0

@graemerocher graemerocher added type: bug Something isn't working type: regression A breaking change was introduced in a minor or patch release labels Jul 3, 2024
@graemerocher graemerocher moved this to Todo in 4.5.1 Release Jul 3, 2024
@graemerocher graemerocher self-assigned this Jul 3, 2024
@graemerocher graemerocher moved this from Todo to In Progress in 4.5.1 Release Jul 5, 2024
graemerocher added a commit that referenced this issue Jul 18, 2024

Verified

This commit was signed with the committer’s verified signature.
baywet Vincent Biret
@graemerocher graemerocher moved this from In Progress to Ready for Review in 4.5.1 Release Jul 18, 2024
graemerocher added a commit that referenced this issue Jul 19, 2024

Verified

This commit was signed with the committer’s verified signature.
baywet Vincent Biret
* Fix enums as each property keys. Fixes #10944
@github-project-automation github-project-automation bot moved this from Ready for Review to Done in 4.5.1 Release Jul 19, 2024
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 type: regression A breaking change was introduced in a minor or patch release
Projects
Status: Done
Development

No branches or pull requests

2 participants