By clearing the XWikiContext in the tearDown of the unit test, I can
stop the memory leak and stop running the tests in isolation. I am
proposing we apply this change because the XWikiContext is created
per test and the worst problem which can be created is tests
erroneously passing which I don't think is very likely from a change
like this.

Jira issue: http://jira.xwiki.org/jira/browse/XWIKI-4953
Patch:
http://jira.xwiki.org/jira/secure/attachment/16788/XWIKI-4496-patchTestMemoryLeak.patch

Patch content:

Index: core/xwiki-core/pom.xml
===================================================================
--- core/xwiki-core/pom.xml     (revision 27357)
+++ core/xwiki-core/pom.xml     (working copy)
@@ -823,10 +823,6 @@
       <plugin>
         <groupId>org.apache.maven.plugins</groupId>
         <artifactId>maven-surefire-plugin</artifactId>
-        <configuration>
-          <!-- Prevent Out Of Memory errors resulting from tests
that do no free up the memory correctly -->
-          <forkMode>pertest</forkMode>
-        </configuration>
       </plugin>
       <!-- Publish a Core Test JAR -->
       <plugin>
Index:
core/xwiki-core/src/test/java/com/xpn/xwiki/test/AbstractBridgedXWikiComponentTestCase.java
===================================================================
---
core/xwiki-core/src/test/java/com/xpn/xwiki/test/AbstractBridgedXWikiComponentTestCase.java
(revision 27357)
+++
core/xwiki-core/src/test/java/com/xpn/xwiki/test/AbstractBridgedXWikiComponentTestCase.java
(working copy)
@@ -80,6 +80,7 @@
     protected void tearDown() throws Exception
     {
         Utils.setComponentManager(null);
+        getContext().clear();
         super.tearDown();
     }


_______________________________________________
devs mailing list
[email protected]
http://lists.xwiki.org/mailman/listinfo/devs

Reply via email to