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

Bug 366589

Summary: XtextRunner caches InjectorProviders
Product: [Modeling] TMF Reporter: Benjamin Schwertfeger <benjamin.schwertfeger>
Component: XtextAssignee: Project Inbox <tmf.xtext-inbox>
Status: CLOSED WORKSFORME QA Contact:
Severity: normal    
Priority: P3 CC: sven.efftinge
Version: 2.2.0   
Target Milestone: ---   
Hardware: PC   
OS: Mac OS X - Carbon (unsup.)   
Whiteboard:

Description Benjamin Schwertfeger CLA 2011-12-13 13:03:23 EST
The XtextRunner caches all InjectorProvider in a static variable.

If your InjectorProvider has a state, like the Injector or the GlobalStateMemento, this leads to growing memory consumption if you call many tests in one JVM. The possibility of side effects between tests in this case is also higher, because you could get an InjectorProvider from a test which ran before.

The InjectorProvider should not be cached over different TestClasses or get a method, like AfterClass in JUnit, to be able to clean the internal state.
Comment 1 Sven Efftinge CLA 2011-12-13 13:36:06 EST
The idea is to reuse the injector to speed up execution. As it is a provider, you could have an implementation which doesn't hold the injector internally, but create a fresh one each time getInjector() is called.

Doesn't that work for you?
Comment 2 Sven Efftinge CLA 2011-12-15 07:24:52 EST
please reopen, if I missed something
Comment 3 Karsten Thoms CLA 2017-09-19 17:41:33 EDT
Closing all bugs that were set to RESOLVED before Neon.0
Comment 4 Karsten Thoms CLA 2017-09-19 17:52:40 EDT
Closing all bugs that were set to RESOLVED before Neon.0