Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 336948

Summary: Potential leak of ContextInjectionListener
Product: z_Archived Reporter: Remy Suen <remy.suen>
Component: E4Assignee: Oleg Besedin <ob1.eclipse>
Status: RESOLVED FIXED QA Contact:
Severity: major    
Priority: P3    
Version: unspecified   
Target Milestone: ---   
Hardware: All   
OS: All   
Whiteboard:
Attachments:
Description Flags
Java test file, this is not a patch.
none
Patch none

Description Remy Suen CLA 2011-02-11 10:38:24 EST
Created attachment 188782 [details]
Java test file, this is not a patch.

This is the _suspected_ reference trace using JDT's ref checking code. Please reproduce with the attached .java file (not a patch!).

org.eclipse.e4.ui.model.application.ui.basic.impl.InputPartImpl
  java.lang.Object[0] -> org.eclipse.e4.ui.model.application.ui.basic.impl.InputPartImpl@893929 (elementId: null, tags: null
  org.eclipse.e4.core.internal.contexts.ContextObjectSupplier$ContextInjectionListener#result -> [Ljava.lang.Object;@88436f
  org.eclipse.e4.core.internal.contexts.TrackableComputationExt#runnable -> PartServiceImpl#setPart()
  org.eclipse.e4.core.internal.contexts.ContextObjectSupplier#outerComputation -> PartServiceImpl#setPart()
  java.util.HashMap$Entry#key -> org.eclipse.e4.core.internal.contexts.ContextObjectSupplier@1f938a8
  java.util.HashMap$Entry[8] -> org.eclipse.e4.core.internal.contexts.ContextObjectSupplier@1f938a8=[java.lang.ref.WeakReference@ff
  java.util.HashMap#table -> [Ljava.util.HashMap$Entry;@ac0382
  org.eclipse.e4.core.internal.di.InjectorImpl#injectedObjects -> {org.eclipse.e4.core.internal.contexts.ContextObjectSupplier@c08593=[java.lang.ref.WeakReference@e5
  org.eclipse.e4.core.contexts.ContextInjectionFactory#injector -> org.eclipse.e4.core.internal.di.InjectorImpl@bb1311
  java.lang.Class -> class org.eclipse.e4.core.contexts.ContextInjectionFactory
Comment 1 Oleg Besedin CLA 2011-02-11 14:01:36 EST
Created attachment 188806 [details]
Patch

The Requestor objects were retaining results of calculations which removed them from GC. The attached patch fixes the issue.

The patch also fixes the injection exception for some cases involving injection of optional fields or methods. That problem is not related to the leak, but I stumbled on it while testing the patch.

The patch also adds a new JUnit InjectionResultLeakTest to the core tests based on the Remy's test.
Comment 2 Oleg Besedin CLA 2011-02-11 14:03:22 EST
Patch applied to CVS Head. Thanks Remy for the test - that made it easy to figure out.
Comment 3 Remy Suen CLA 2011-02-11 14:05:45 EST
(In reply to comment #1)
> The patch also fixes the injection exception for some cases involving injection
> of optional fields or methods. That problem is not related to the leak, but I
> stumbled on it while testing the patch.

Can this problem manifest itself easily in the form of a test case or is it a rare error condition?