Skip to content

Fix Lazy Checked Exceptions #737

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Merged
merged 4 commits into from
Nov 19, 2024
Merged

Fix Lazy Checked Exceptions #737

merged 4 commits into from
Nov 19, 2024

Conversation

SentryMan
Copy link
Collaborator

@SentryMan SentryMan commented Nov 18, 2024

Currently, this generates invalid code:

@Singleton
public class LazyBean {
  @Inject Provider<Integer> intProvider;

  public LazyBean() throws Exception {}
}

Now properly generates code:

@Generated("io.avaje.inject.generator")
public final class LazyBean$DI  {

  public static void build(Builder builder) {
    if (builder.isAddBeanFor(LazyBean.class)) {
      builder.registerProvider(() -> {
      try {
          var bean = new LazyBean();
          bean.intProvider = builder.getProvider(Integer.class);
          return bean;
      } catch (Throwable e) {
        throw new RuntimeException("Error during wiring", e);
      }
     });
    }
  }

}

@SentryMan SentryMan added the bug Something isn't working label Nov 18, 2024
@SentryMan SentryMan added this to the 10.6 milestone Nov 18, 2024
@SentryMan SentryMan requested a review from rbygrave November 18, 2024 04:45
@SentryMan SentryMan self-assigned this Nov 18, 2024
@SentryMan SentryMan enabled auto-merge November 18, 2024 04:48
@SentryMan SentryMan merged commit cfc8399 into avaje:master Nov 19, 2024
7 checks passed
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants