Skip to content

Commit f74064d

Browse files
Harsh GuptaHarsh Gupta
Harsh Gupta
authored and
Harsh Gupta
committed
Retrieving properties from property list using iterator and while loop instead of chained functions
1 parent a294569 commit f74064d

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

core/src/main/scala/org/apache/spark/rpc/RpcEnv.scala

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -264,9 +264,15 @@ object RpcTimeout {
264264
require(timeoutPropList.nonEmpty)
265265

266266
// Find the first set property or use the default value with the first property
267-
val foundProp = timeoutPropList.view.map(x => (x, conf.getOption(x))).filter(_._2.isDefined).
268-
map(y => (y._1, y._2.get)).headOption.getOrElse(timeoutPropList.head, defaultValue)
269-
267+
val itr = timeoutPropList.iterator
268+
var foundProp = (timeoutPropList.head,defaultValue)
269+
while (itr.hasNext){
270+
val propKey = itr.next()
271+
conf.getOption(propKey) match {
272+
case Some(prop) => foundProp = (propKey,prop)
273+
case None =>
274+
}
275+
}
270276
val timeout = { Utils.timeStringAsSeconds(foundProp._2) seconds }
271277
new RpcTimeout(timeout, messagePrefix + foundProp._1)
272278
}

0 commit comments

Comments
 (0)