Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 363856 - [DI] Erroneous field injection?
Summary: [DI] Erroneous field injection?
Status: VERIFIED FIXED
Alias: None
Product: Platform
Classification: Eclipse Project
Component: UI (show other bugs)
Version: 4.2   Edit
Hardware: PC Mac OS X - Carbon (unsup.)
: P3 normal (vote)
Target Milestone: 4.2 M4   Edit
Assignee: Oleg Besedin CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-11-15 13:16 EST by Brian de Alwis CLA
Modified: 2012-01-24 13:31 EST (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Brian de Alwis CLA 2011-11-15 13:16:51 EST
BuildId: I20111028-1100
OS: MacOS X (only because it demonstrates the problem)

The CocoaUIProcessor requests the MApplication through injection.  But an interesting thing occurs: when the MApplication instance is set (in E4Application#createE4Workbench()), the injector actually tries to inject with a created instance of MApplication, which fails.  This can be seen if you place a breakpoint on InjectionException:

Daemon Thread [Thread-1] (Suspended (exception InjectionException))	
	InjectorImpl.internalMake(Class<?>, PrimaryObjectSupplier, PrimaryObjectSupplier) line: 326	
	InjectorImpl.resolveArgs(Requestor, PrimaryObjectSupplier, PrimaryObjectSupplier, boolean, boolean, boolean) line: 450	
	InjectorImpl.resolveArguments(IRequestor, boolean) line: 334	
	FieldRequestor(Requestor).resolveArguments(boolean) line: 115	
	ContextObjectSupplier$ContextInjectionListener.update(IEclipseContext, int, Object[]) line: 76	
	TrackableComputationExt.update(ContextChangeEvent) line: 106	
	EclipseContext.processScheduled(Set<Scheduled>) line: 307	
	EclipseContext.set(String, Object) line: 321	
	E4Application.createE4Workbench(IApplicationContext, Display) line: 231	

(I often trap InjectionException as it seems the best way to discover why a handler isn't being invoked.)
Comment 1 Oleg Besedin CLA 2011-11-15 14:53:55 EST
If I understand the description right, this seem like a result of the change in the bug 302533.

Is that correct? How can I duplicate the problem (and where is the CocoaUIProcessor coming from)?
Comment 2 Brian de Alwis CLA 2011-11-17 08:03:19 EST
(In reply to comment #1)
> If I understand the description right, this seem like a result of the change in
> the bug 302533.

Maybe, although in this case there is a value available in the context.

> Is that correct? How can I duplicate the problem (and where is the
> CocoaUIProcessor coming from)?

The CocoaUIProcessor is part of the org.eclipse.e4.ui.workbench.renderers.swt.cocoa fragment, and installed by default.  (I vaguely recall that you had a mac, so this would be an easy demo of the issue.)
Comment 3 Oleg Besedin CLA 2011-11-17 14:10:53 EST
Thank you, I can duplicate the problem. (My Git repo was messed up on Mac.)

There seems to be two issues there:
- Originally ModelAssembler#runProcessor() injects CocoaUIProcessor with a context that gets disposed (localContext.dispose());
- The CocoaUIProcessor gets update notification even through its context was disposed.

I'll look into those.
Comment 4 Oleg Besedin CLA 2011-11-21 14:11:43 EST
(In reply to comment #3)
> There seems to be two issues there:
> - Originally ModelAssembler#runProcessor() injects CocoaUIProcessor with a
> context that gets disposed (localContext.dispose());

Fixed:
http://git.eclipse.org/c/platform/eclipse.platform.ui.git/commit/?id=0e5242977d5dd079aa45de99c7d85d1e41f5b60a

> - The CocoaUIProcessor gets update notification even through its context was
> disposed.

Fixed:
http://git.eclipse.org/c/platform/eclipse.platform.runtime.git/commit/?id=c8d5768a057413a47ccfd713aa89b2b3b01f25e4
Comment 5 Brian de Alwis CLA 2012-01-24 13:31:15 EST
Verified in I20120123-2200 — it doesn't happen in any of my sample apps.