| Summary: | [DI] ContextInjectionFactory.make on nested class within @PostConstruct method of outer class leads to endless recursion | ||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
| Product: | [Eclipse Project] Platform | Reporter: | Paul Reuter <preuter> | ||||||||
| Component: | Runtime | Assignee: | Oleg Besedin <ob1.eclipse> | ||||||||
| Status: | RESOLVED FIXED | QA Contact: | |||||||||
| Severity: | normal | ||||||||||
| Priority: | P3 | CC: | ob1.eclipse, remy.suen | ||||||||
| Version: | 4.1 | ||||||||||
| Target Milestone: | 4.2 M1 | ||||||||||
| Hardware: | PC | ||||||||||
| OS: | Mac OS X - Carbon (unsup.) | ||||||||||
| Whiteboard: | |||||||||||
| Attachments: |
|
||||||||||
|
Description
Paul Reuter
Created attachment 186923 [details]
Is this the problem?
Can you attach sample code that causes endless recursion? I tried to follow your description but what I am getting is an InjectionException which is more-or-less what is expected, see the attached code.
Ah, I found the reason your test case does not reproduce the bug: in org.eclipse.e4.core.internal.di.InjectorImpl.internalMake:298 // unless this is the default constructor, it has to be tagged if (!constructor.isAnnotationPresent(Inject.class) && constructor.getParameterTypes().length != 0) continue; Adding @Inject to the constructor of the nested class does the trick for me. The reason for the endless recursion is the following: In org.eclipse.e4.core.internal.di.InjectorImpl.resolveArgs:391, the argument descriptors returned by org.eclipse.e4.core.internal.di.ConstructorRequestor.getDependentObjects() include the outer class as first argument, which is then later created, thereby triggering the @PostConstruct and subsequent endless recursion. On a related note, the necessity of the @Inject annotation on the default constructor is also a bug, I think. Since the default constructor of a nested class has the outer class as first parameter, it is not recognized as default constructor by the code-snippet above. Created attachment 187005 [details]
Trying to duplicate
Hmm... I've added @Inject to constructor and still getting an injection exception, not an endless loop.
Oh my, found some egg on my face. I never actually ran this bug in "Run" mode, which pops up an InjectionException after a few seconds (still outrageous for something so simple). In debug mode, this takes long enough that I never actually waited it out, so I did not realize the unspectacular ending. Could you place a breakpoint in the @PostConstruct method and observe if you hit it more than the one time that is expected? Created attachment 198265 [details]
Patch
Patch applied to CVS Head. Thanks Paul for taking time to figure this out! |