Skip to content

Commit f1d73e3

Browse files
committed
mergeConfs returns a copy rather than mutating one of the input arguments
1 parent 0f5cd84 commit f1d73e3

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

core/src/main/scala/org/apache/spark/api/python/PythonHadoopUtil.scala

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,12 @@ private[python] object PythonHadoopUtil {
1414
conf
1515
}
1616

17-
/* Merges two configurations, keys from right overwrite any matching keys in left */
17+
/* Merges two configurations, returns a copy of left with keys from right overwriting any matching keys in left */
1818
def mergeConfs(left: Configuration, right: Configuration) = {
1919
import collection.JavaConversions._
20-
right.iterator().foreach(entry => left.set(entry.getKey, entry.getValue))
21-
left
20+
val copy = new Configuration(left)
21+
right.iterator().foreach(entry => copy.set(entry.getKey, entry.getValue))
22+
copy
2223
}
2324

2425
}

0 commit comments

Comments
 (0)