Skip to content

Use appropriate scope in producer methods#4031

Merged
adutra merged 1 commit intoapache:mainfrom
adutra:fix-producer-method-scope
Mar 20, 2026
Merged

Use appropriate scope in producer methods#4031
adutra merged 1 commit intoapache:mainfrom
adutra:fix-producer-method-scope

Conversation

@adutra
Copy link
Contributor

@adutra adutra commented Mar 19, 2026

Some producer methods are not annotated, which means that the produced beans get the @Dependent scope by default. This is incorrect for some of the beans. This PR fixes it.

Checklist

  • 🛡️ Don't disclose security issues! (contact security@apache.org)
  • 🔗 Clearly explained why the changes are needed, or linked related issues: Fixes #
  • 🧪 Added/updated tests with good coverage, or manually tested (and explained how)
  • 💡 Added comments for complex logic
  • 🧾 Updated CHANGELOG.md (if needed)
  • 📚 Updated documentation in site/content/in-dev/unreleased (if needed)

@github-project-automation github-project-automation bot moved this to PRs In Progress in Basic Kanban Board Mar 19, 2026
@adutra adutra changed the title Use appropriate scope producer methods Use appropriate scope in producer methods Mar 19, 2026
Some producer methods are not annotated, which means that the produced beans get the `@Dependent` scope by default. This is incorrect for some of the beans. This PR fixes it.
@adutra adutra force-pushed the fix-producer-method-scope branch from 03a4dd8 to c10b903 Compare March 19, 2026 22:19
// Polaris service beans - selected from @Identifier-annotated beans

@Produces
@Singleton // used in instanceof checks
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

instanceof on a CDI bean looks like an anti-pattern to me. This PR is still a good fix for the scope problem, but we should probably revisit those instanceof checks... WDYT?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree. We have instanceof checks in production AND test code... but most test code. It's going to take some time to fix them all.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure. Let's do it gradually after this PR :)

@github-project-automation github-project-automation bot moved this from PRs In Progress to Ready to merge in Basic Kanban Board Mar 19, 2026
@adutra adutra merged commit 470104f into apache:main Mar 20, 2026
18 checks passed
@github-project-automation github-project-automation bot moved this from Ready to merge to Done in Basic Kanban Board Mar 20, 2026
@adutra adutra deleted the fix-producer-method-scope branch March 20, 2026 18:32
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