forked from typelevel/scala
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request scala#4280 from kanielc/SI-9095
SI-9095 Memory leak in LinkedHasMap and LinkedHashSet
- Loading branch information
Showing
4 changed files
with
52 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
25 changes: 25 additions & 0 deletions
25
test/junit/scala/collection/mutable/LinkedHashMapTest.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package scala.collection.mutable | ||
|
||
import org.junit.runner.RunWith | ||
import org.junit.runners.JUnit4 | ||
import org.junit.{ Assert, Test } | ||
|
||
import scala.collection.mutable | ||
|
||
/* Test for SI-9095 */ | ||
@RunWith(classOf[JUnit4]) | ||
class LinkedHashMapTest { | ||
class TestClass extends mutable.LinkedHashMap[String, Int] { | ||
def lastItemRef = lastEntry | ||
} | ||
|
||
@Test | ||
def testClear: Unit = { | ||
val lhm = new TestClass | ||
Seq("a" -> 8, "b" -> 9).foreach(kv => lhm.put(kv._1, kv._2)) | ||
|
||
Assert.assertNotNull(lhm.lastItemRef) | ||
lhm.clear() | ||
Assert.assertNull(lhm.lastItemRef) | ||
} | ||
} |
25 changes: 25 additions & 0 deletions
25
test/junit/scala/collection/mutable/LinkedHashSetTest.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package scala.collection.mutable | ||
|
||
import org.junit.runner.RunWith | ||
import org.junit.runners.JUnit4 | ||
import org.junit.{ Assert, Test } | ||
|
||
import scala.collection.mutable | ||
|
||
/* Test for SI-9095 */ | ||
@RunWith(classOf[JUnit4]) | ||
class LinkedHashSetTest { | ||
class TestClass extends mutable.LinkedHashSet[String] { | ||
def lastItemRef = lastEntry | ||
} | ||
|
||
@Test | ||
def testClear: Unit = { | ||
val lhs = new TestClass | ||
Seq("a", "b").foreach(k => lhs.add(k)) | ||
|
||
Assert.assertNotNull(lhs.lastItemRef) | ||
lhs.clear() | ||
Assert.assertNull(lhs.lastItemRef) | ||
} | ||
} |