Skip to content

Conversation

SentryMan
Copy link
Collaborator

Currently, the processor adds the supertypes of java.lang classes as keys for wiring. When beans are supplied manually this can cause issues.

Given:

public enum State {
    ON, OFF
}

@Factory
public class Configuration {

    @Bean
    public State state() {
        return State.ON;
    }
}

Before:

  public static void build_state(Builder builder) {
    if (builder.isAddBeanFor(State.class, TYPE_EnumState, Constable.class, Comparable.class, Serializable.class)) {
      var factory = builder.get(Configuration.class);
      var bean = factory.state();
      builder.register(bean);
    }
  }

After:

  public static void build_state(Builder builder) {
    if (builder.isAddBeanFor(State.class)) {
      var factory = builder.get(Configuration.class);
      var bean = factory.state();
      builder.register(bean);
    }
  }

Fixes #710

@SentryMan SentryMan added the bug Something isn't working label Oct 27, 2024
@SentryMan SentryMan added this to the 10.5 milestone Oct 27, 2024
@SentryMan SentryMan self-assigned this Oct 27, 2024
@SentryMan SentryMan requested a review from rbygrave October 27, 2024 18:53
@rbygrave rbygrave merged commit 8544e40 into avaje:master Oct 28, 2024
7 checks passed
@SentryMan SentryMan deleted the fix-enum branch October 28, 2024 21:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

A @Bean of Enum injection

2 participants