In this code in foreach I am getting task not serialized exception
@SuppressWarnings("serial")
public static void matchAndMerge(JavaRDD<VendorRecord> matchRdd, final
JavaSparkContext jsc) throws IOException{
log.info("Company matcher started");
//final JavaSparkContext jsc = getSparkContext();
matchRdd.foreachAsync(new VoidFunction<VendorRecord>(){
@Override
public void call(VendorRecord t) throws Exception {
if(t !=null){
try{
CompanyMatcherHelper.UpdateMatchedRecord(jsc,t);
} catch (Exception e) {
log.error("ERROR while running Matcher for company " + t.getCompanyId(), e);
}
}
}
});
}