From f74064df7c00af07ab2cc63d8bb035dea45a0368 Mon Sep 17 00:00:00 2001 From: Harsh Gupta Date: Thu, 21 May 2015 23:36:02 +0530 Subject: [PATCH] Retrieving properties from property list using iterator and while loop instead of chained functions --- .../src/main/scala/org/apache/spark/rpc/RpcEnv.scala | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/core/src/main/scala/org/apache/spark/rpc/RpcEnv.scala b/core/src/main/scala/org/apache/spark/rpc/RpcEnv.scala index 71924475826d9..c8aab1e1ab405 100644 --- a/core/src/main/scala/org/apache/spark/rpc/RpcEnv.scala +++ b/core/src/main/scala/org/apache/spark/rpc/RpcEnv.scala @@ -264,9 +264,15 @@ object RpcTimeout { require(timeoutPropList.nonEmpty) // Find the first set property or use the default value with the first property - val foundProp = timeoutPropList.view.map(x => (x, conf.getOption(x))).filter(_._2.isDefined). - map(y => (y._1, y._2.get)).headOption.getOrElse(timeoutPropList.head, defaultValue) - + val itr = timeoutPropList.iterator + var foundProp = (timeoutPropList.head,defaultValue) + while (itr.hasNext){ + val propKey = itr.next() + conf.getOption(propKey) match { + case Some(prop) => foundProp = (propKey,prop) + case None => + } + } val timeout = { Utils.timeStringAsSeconds(foundProp._2) seconds } new RpcTimeout(timeout, messagePrefix + foundProp._1) }