diff options
author | Lukas Rytz <lukas.rytz@typesafe.com> | 2015-03-23 20:25:50 +0100 |
---|---|---|
committer | Lukas Rytz <lukas.rytz@typesafe.com> | 2015-03-23 20:25:50 +0100 |
commit | 4d4eb913eccd6b8ef691ca249ec6d0f49649dc2e (patch) | |
tree | b3dbb0b4fb40748ecbee405c53db3abd89a08f68 /src/library | |
parent | 917602cd706a9e44d347ba2f58c0c63ccab8746c (diff) | |
parent | 17caf79d158ca13776dff6d7461bba362b7a2f2f (diff) | |
download | scala-4d4eb913eccd6b8ef691ca249ec6d0f49649dc2e.tar.gz scala-4d4eb913eccd6b8ef691ca249ec6d0f49649dc2e.tar.bz2 scala-4d4eb913eccd6b8ef691ca249ec6d0f49649dc2e.zip |
Merge pull request #4372 from som-snytt/issue/7775-tweak
SI-7775 Exclude nulls when iterating sys props
Diffstat (limited to 'src/library')
-rw-r--r-- | src/library/scala/sys/SystemProperties.scala | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/src/library/scala/sys/SystemProperties.scala b/src/library/scala/sys/SystemProperties.scala index d2ebf8c044..6f8b13a89b 100644 --- a/src/library/scala/sys/SystemProperties.scala +++ b/src/library/scala/sys/SystemProperties.scala @@ -35,8 +35,15 @@ extends mutable.AbstractMap[String, String] override def empty = new SystemProperties override def default(key: String): String = null - def iterator: Iterator[(String, String)] = - wrapAccess(System.getProperties().asScala.iterator) getOrElse Iterator.empty + def iterator: Iterator[(String, String)] = wrapAccess { + val ps = System.getProperties() + names map (k => (k, ps getProperty k)) filter (_._2 ne null) + } getOrElse Iterator.empty + + def names: Iterator[String] = wrapAccess ( + System.getProperties().stringPropertyNames().asScala.iterator + ) getOrElse Iterator.empty + def get(key: String) = wrapAccess(Option(System.getProperty(key))) flatMap (x => x) override def contains(key: String) = |