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

Arc: CDI Decorators and interface methods with default implementations #35664

Closed
mederel opened this issue Aug 31, 2023 · 2 comments · Fixed by #35674
Closed

Arc: CDI Decorators and interface methods with default implementations #35664

mederel opened this issue Aug 31, 2023 · 2 comments · Fixed by #35674
Assignees
Labels
area/arc Issue related to ARC (dependency injection) kind/bug Something isn't working
Milestone

Comments

@mederel
Copy link
Contributor

mederel commented Aug 31, 2023

Describe the bug

Found a tricky bug while using CDI Decorators based on an interface that has methods with default implementations.

Example:

interface Interface {
  default int getWithDefault() { return 3; }
}

@Decorator
class InterfaceDecorator implements Interface {
  @Inject
  @Delegate
  Interface delegate;

  public int getWithDefault() {
    return delegate.getWithDefault();
  }
}

@Dependent
class ConcreteImplementation implements Interface {
  @Override
  public int getWithDefault() {
    return 4;
  }
}

class User {
  @Inject
  Interface anInterface;

  public void call() {
    assert: anInterface.getWithDefault() == 4; // value of concrete implementation
  }
}

This code will end in an AssertionError cause the concerte implementation never gets called.

Expected behavior

Interface methods with default implementation are still override by the container to forwarding calls from one decorator to another till the concrete implementation of the type.

Actual behavior

Calls to interface methods with default implementation are not forwarded by the container from the first decorator to the second decorator or the actual implementation.

How to Reproduce?

Reproducer:
reproducer-decorator-default-impl.zip

Run mvn clean install after unzip.

Output of uname -a or ver

6.2.0 Ubuntu

Output of java -version

20.0.2

GraalVM version (if different from Java)

23.0.1

Quarkus version or git rev

3.3.1

Build tool (ie. output of mvnw --version or gradlew --version)

Apache Maven 3.9.4

Additional information

No response

@mederel mederel added the kind/bug Something isn't working label Aug 31, 2023
@quarkus-bot quarkus-bot bot added the area/arc Issue related to ARC (dependency injection) label Aug 31, 2023
@quarkus-bot
Copy link

quarkus-bot bot commented Aug 31, 2023

/cc @Ladicek (arc), @manovotn (arc), @mkouba (arc)

@mederel
Copy link
Contributor Author

mederel commented Aug 31, 2023

The default methods are definitely removed after this contribution:

https://github.com/quarkusio/quarkus/pull/33841/files#diff-f05a30ce973915337c900f71476c739f710d3fcc1ab6d148bbb418755a2bd5a9

But when I try to remove the condition, obviously few tests start failing again:

[ERROR] Errors: 
[ERROR]   MultipleDecoratorsWithTypeVariablesTest.testConsumer » NullPointer
[ERROR]   MultipleDecoratorsWithTypeVariablesTest.testFunction » NullPointer
[ERROR]   MultipleDecoratorsWithTypeVariablesTest.testSupplier » NullPointer
[ERROR]   SlightlyMoreComplexDecoratorWithTypeVariableTest.testFunction » NullPointer

I don't think I am in a position to propose a fix.

@mkouba mkouba self-assigned this Sep 1, 2023
mkouba added a commit to mkouba/quarkus that referenced this issue Sep 1, 2023
@quarkus-bot quarkus-bot bot added this to the 3.4 - main milestone Sep 1, 2023
@gsmet gsmet modified the milestones: 3.4 - main, 3.3.2 Sep 4, 2023
gsmet pushed a commit to gsmet/quarkus that referenced this issue Sep 4, 2023
@aloubyansky aloubyansky modified the milestones: 3.3.2, 3.2.8.Final Oct 31, 2023
aloubyansky pushed a commit to aloubyansky/quarkus that referenced this issue Oct 31, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/arc Issue related to ARC (dependency injection) kind/bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants