Skip to content

Clarify that WeldInitiator.from() and WeldInitiator.of() should use the same variable scope #168

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

Merged
merged 1 commit into from
Jan 30, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 12 additions & 2 deletions junit5/src/main/java/org/jboss/weld/junit5/WeldInitiator.java
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,13 @@ public static WeldInitiator of(Class<?>... beanClasses) {

/**
* The container is configured through a provided {@link Weld} instance.
* <p>
* Provided instance of {@link Weld} should be kept in the same scope as the resulting {@link WeldInitiator}.
* I.e. if {@link Weld} instance is kept in a static field, so should be the resulting {@link WeldInitiator}.
* Failing to uphold this can lead to repetitive configuration of the same {@link Weld} instance which in turn results in
* unexpected container setup/behavior.
*
* @param weld
* @param weld instance of {@link Weld} used to create {@link WeldInitiator}
* @return a new WeldInitiator instance
*/
public static WeldInitiator of(Weld weld) {
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

In theory, this method shouldn't exhibit the problem as it returns WeldInitiator directly instead of returning a still-configurable Builder object but I added it here anyway for the sake of consistency.

Expand Down Expand Up @@ -120,8 +125,13 @@ public static Builder from(Class<?>... beanClasses) {

/**
* Create a builder instance.
* <p>
* Provided instance of {@link Weld} should be kept in the same scope as the resulting {@link WeldInitiator}.
* I.e. if {@link Weld} instance is kept in a static field, so should be the resulting {@link WeldInitiator}.
* Failing to uphold this can lead to repetitive configuration of the same {@link Weld} instance which in turn results in
* unexpected container setup/behavior.
*
* @param weld
* @param weld instance of {@link Weld} used as a basis for this {@link WeldInitiator.Builder}
* @return a builder instance
* @see #of(Weld)
*/
Expand Down