This writeup describes a tricky Scala serialization issue that we ran into while porting Spark to Scala 2.11.
First, let's create a factory that builds anonymous functions:
class FunctionFactory extends Serializable {
// This method returns a function whose $outer scope is this class.
// Note that the function does not reference any variables in this scope,