Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 336948 - Potential leak of ContextInjectionListener
Summary: Potential leak of ContextInjectionListener
Status: RESOLVED FIXED
Alias: None
Product: z_Archived
Classification: Eclipse Foundation
Component: E4 (show other bugs)
Version: unspecified   Edit
Hardware: All All
: P3 major (vote)
Target Milestone: ---   Edit
Assignee: Oleg Besedin CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-02-11 10:38 EST by Remy Suen CLA
Modified: 2012-12-13 15:00 EST (History)
0 users

See Also:


Attachments
Java test file, this is not a patch. (3.61 KB, text/plain)
2011-02-11 10:38 EST, Remy Suen CLA
no flags Details
Patch (8.10 KB, patch)
2011-02-11 14:01 EST, Oleg Besedin CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
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?