Skip to content

Commit de1d294

Browse files
committed
SI-9583: Update SystemProperties.empty to return a mutable.Map to fix builders
1 parent d5c74a2 commit de1d294

File tree

2 files changed

+28
-1
lines changed

2 files changed

+28
-1
lines changed

src/library/scala/sys/SystemProperties.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ class SystemProperties
3232
extends mutable.AbstractMap[String, String]
3333
with mutable.Map[String, String] {
3434

35-
override def empty = new SystemProperties
35+
override def empty = mutable.Map[String, String]()
3636
override def default(key: String): String = null
3737

3838
def iterator: Iterator[(String, String)] = wrapAccess {
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
package scala.util
2+
3+
import org.junit.runner.RunWith
4+
import org.junit.runners.JUnit4
5+
import org.junit.Test
6+
import org.junit.Assert._
7+
8+
@RunWith(classOf[JUnit4])
9+
class SystemPropertiesTest {
10+
@Test
11+
def filterAll(): Unit = {
12+
val isEmpty = sys.props.filter(_ => false).size == 0
13+
assertTrue("A filter matching nothing should produce an empty result", isEmpty)
14+
}
15+
16+
@Test
17+
def filterNone(): Unit = {
18+
val isUnchanged = sys.props.filter(_ => true) == sys.props
19+
assertTrue("A filter matching everything should not change the result", isUnchanged)
20+
}
21+
22+
@Test
23+
def empty(): Unit = {
24+
val hasSize0 = sys.props.empty.size == 0
25+
assertTrue("SystemProperties.empty should have size of 0", hasSize0)
26+
}
27+
}

0 commit comments

Comments
 (0)