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

Bug fix for @Bean returning Optional not registering extended type #782

Merged
merged 2 commits into from
Mar 26, 2025

Conversation

rbygrave
Copy link
Contributor

Example:

@Bean
Optional<CFace> optional() { ... }

The generated isBeanAbsent() method should include all the types that CFace extends such as interfaces. If CFace extends C2Face then both should be there like:

.isBeanAbsent(CFace.class, C2Face.class)

The bug was that only the top type of CFace was included like:

.isBeanAbsent(CFace.class)

This was due to a bug in MethodReader determining the incorrect returnElement for the optionalType = true case. The returnElement was the Optional type rather than the parameter type CFace.

Example:
```
@bean
Optional<CFace> optional() { ... }
```

The generated isBeanAbsent() method should include all the types that CFace extends such as interfaces. If CFace extends C2Face then both should be there like:

.isBeanAbsent(CFace.class, C2Face.class))

The bug was that only the top type of CFace was included like:

```
.isBeanAbsent(CFace.class))
```

This was due to a bug in MethodReader determining the incorrect returnElement for the optionalType = true case. The returnElement was the Optional type rather than the parameter type CFace.
@rbygrave rbygrave requested a review from SentryMan March 26, 2025 08:04
@rbygrave rbygrave self-assigned this Mar 26, 2025
@rbygrave rbygrave enabled auto-merge (squash) March 26, 2025 08:06
@rbygrave rbygrave merged commit afab32d into master Mar 26, 2025
13 checks passed
@SentryMan SentryMan deleted the feature/fix-optional-extends branch March 26, 2025 17:02
@SentryMan SentryMan added this to the 11.4 milestone Mar 27, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants