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

Injecting null for X name:!controller when creating class X$Route - potential beans to inject ... #408

Closed
rbygrave opened this issue Oct 9, 2023 · 0 comments · Fixed by #409
Assignees
Labels
bug Something isn't working
Milestone

Comments

@rbygrave
Copy link
Contributor

rbygrave commented Oct 9, 2023

Getting an error when creating the BeanScope when using Aspects on a bean that is not public (package protected).

How to reproduce:

Add a package protected access on a bean with an aspect like:

@Singleton
class OtherService {  //. <!-- package protected access

  @MyAround // <!-- ASPECT
  public String other(...) {
   ...
  }

Have another bean that depends on it like:

@Singleton
class OtherUserOf {

  final OtherService otherService;

  OtherUserOf(OtherService otherService) {
    this.otherService = otherService;
  }
}

The issue:

When OtherService is public access we see in the generated code:

  @DependencyMeta(
      type = "org.example.myapp.OtherService$Proxy",
      provides = {"org.example.myapp.OtherService"},
      dependsOn = {
        "io.avaje.inject.aop.AspectProvider<org.example.myapp.aspect.MyAround>",
        "io.avaje.inject.aop.AspectProvider<org.example.myapp.aspect.MyTimed>"
      })
  private void build_myapp_OtherService$Proxy() {
    OtherService$Proxy$DI.build(builder);
  }

Specifically we see that the OtherService$Proxy provides org.example.myapp.OtherService.

When OtherService is package protected, then that provides clause is not generated. This causes the issue as the provides is used to control the ordering of the wiring and now that it is missing the OtherService$Proxy can wire / be created AFTER OtherUserOf and produce the error.

The reason for this is that generally when A extends B then we only say that A provides B when B is public.

We need to adjust this logic for the case when A is a proxy. Here we have OtherService$Proxy extends OtherService and we need avaje-inject to say that OtherService$Proxy provides OtherService even when it is package protected.

@rbygrave rbygrave self-assigned this Oct 9, 2023
@rbygrave rbygrave added this to the 9.8 milestone Oct 9, 2023
@rbygrave rbygrave added the bug Something isn't working label Oct 9, 2023
@rbygrave rbygrave linked a pull request Oct 9, 2023 that will close this issue
rbygrave added a commit that referenced this issue Oct 9, 2023
#408 - Support for package protected bean with AOP aspect
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 a pull request may close this issue.

1 participant