-
Notifications
You must be signed in to change notification settings - Fork 78
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
Document the need to destroy a bean that was injected via Instance #584
Comments
In the last part of the [paragraph about
I am not sure if there are other mentions TBH.
It is exactly what it states - constructed (instantiated by CDI) and having its dependencies injected. And, for the most part, managed. But in some cases it is plain impossible for CDI container to do, see below. Resolving dependent bean from an Hope this^ makes sense, feel free to ask further questions :-) |
This sentence comes from the
It is managed by the container. However, as mandated by the spec the container must retain all That said, it would not hurt to mention this specific behavior in the javadoc of |
The problem is that I see no mention of it either anywhere in the javadocs. My suggestion is to document whatever is needed to allow programmers to avoid this pitfall, regardless of the exact definition of managed and an out in the form of "we told you so in the specs" :) For what it's worth, the |
Well, yea. Except it's injected into an EJB bean which isn't by definition a standard CDI bean but I get your point.
I am not sure how to easily describe it in javadoc because like I said, in many cases, this won't be an issue and won't cause a leak and encouraging users to always destroy instances created from
(poor wording, I know; it's just the first thing that I thought of :)) |
Something like that seems fine. I would just add how to destroy it:
Preferably, a short code example similar to what I had in mind can also be added. I, too, called the
|
Note that a Maybe we should also mention the
That's a very bad practice IMO. |
Ah, then remove the
Looks like a good idea.
I agree, but in my case I only know which bean out of many I need during runtime only. I won't be surprised if there's a better pattern to do that. |
@starksm64 In what PR was this fixed? I would like to see the new wording. |
I think this was closed because of the tracking issue under injection API?
I wouldn't mind seeing a PR for it :-) |
I think the issue in AtInject is incorrect, as |
Yes, and it boils down to where we want to document it (and I agree |
Since AtInject's |
As written in the post, it is necessary to manually destroy beans created with
Instance#get
. The current documentation only saysI would say that "fully-constructed and injected" gives the impression that it is managed by the container. This will cause unobvious memory leaks. I would suggest adding something along the lines of:
The text was updated successfully, but these errors were encountered: