I have a class defining an inner static class (map function). The inner class tries to refer the variable instantiated in the outside class, which results in a NullPointerException. Sample Code as follows:
class SampleOuterClass { private static ArrayList<String> someVariable; SampleOuterClass() { // initialize someVariable } public static class Parse implements Function<...> { public TypeReturn call (...) { // Try using someVariable: *Raises NullPointerException* } } public void run() { RDD<> rdd = data.map(new Parse()).rdd() } } Am I missing something with how Closures work with Spark or something else is wrong ? Thanks Sunny