ant-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From maart...@apache.org
Subject svn commit: r644911 - in /ant/ivy/core/trunk: CHANGES.txt src/java/org/apache/ivy/core/module/id/ModuleRevisionId.java
Date Fri, 04 Apr 2008 20:56:23 GMT
Author: maartenc
Date: Fri Apr  4 13:56:22 2008
New Revision: 644911

URL: http://svn.apache.org/viewvc?rev=644911&view=rev
Log:
FIX: Memory leak in ModuleRevisionId.java (IVY-791)

Modified:
    ant/ivy/core/trunk/CHANGES.txt
    ant/ivy/core/trunk/src/java/org/apache/ivy/core/module/id/ModuleRevisionId.java

Modified: ant/ivy/core/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/ant/ivy/core/trunk/CHANGES.txt?rev=644911&r1=644910&r2=644911&view=diff
==============================================================================
--- ant/ivy/core/trunk/CHANGES.txt (original)
+++ ant/ivy/core/trunk/CHANGES.txt Fri Apr  4 13:56:22 2008
@@ -78,6 +78,7 @@
 - IMPROVEMENT: Change allownomd and skipbuildwithoutivy into a more semantically correct
name (IVY-297)
 - IMPROVEMENT: Smarter determination if an expression is exact or not for RegexpPatternMatcher
and GlobPatternMatcher
 
+- FIX: Memory leak in ModuleRevisionId.java (IVY-791)
 - FIX: conflict manager scoping does not work as expected (IVY-465)
 - FIX: ivy.original.xml file using artifact pattern in cache and causing problems (IVY-787)
 - FIX: ivy:retrieve with sync="true" removes the .svn directory (IVY-763)

Modified: ant/ivy/core/trunk/src/java/org/apache/ivy/core/module/id/ModuleRevisionId.java
URL: http://svn.apache.org/viewvc/ant/ivy/core/trunk/src/java/org/apache/ivy/core/module/id/ModuleRevisionId.java?rev=644911&r1=644910&r2=644911&view=diff
==============================================================================
--- ant/ivy/core/trunk/src/java/org/apache/ivy/core/module/id/ModuleRevisionId.java (original)
+++ ant/ivy/core/trunk/src/java/org/apache/ivy/core/module/id/ModuleRevisionId.java Fri Apr
 4 13:56:22 2008
@@ -17,6 +17,7 @@
  */
 package org.apache.ivy.core.module.id;
 
+import java.lang.ref.WeakReference;
 import java.util.HashMap;
 import java.util.Iterator;
 import java.util.Map;
@@ -143,12 +144,19 @@
      * @return an interned ModuleRevisionId
      */
     public static ModuleRevisionId intern(ModuleRevisionId moduleRevisionId) {
-        ModuleRevisionId r = (ModuleRevisionId) CACHE.get(moduleRevisionId);
-        if (r == null) {
-            r = moduleRevisionId;
-            CACHE.put(r, r);
+        ModuleRevisionId r = null;
 
+        synchronized (CACHE) {
+            WeakReference ref = (WeakReference) CACHE.get(moduleRevisionId);
+            if (ref != null) {
+                r = (ModuleRevisionId) ref.get();
+            }
+            if (r == null) {
+                r = moduleRevisionId;
+                CACHE.put(r, new WeakReference(r));
+            }
         }
+     
         return r;
     }
 



Mime
View raw message