Spark/scala code to load json files failing randomly with error java.nio.charset.MalformedInputException

62 Views Asked by At

Below spark code to load json file is failing sometimes. Json files always have utf-8 encoding only. Our spark jar is invoked thru AbInitio Graph which is scheduled to run in TWS. Backend execution runs fine but running thru TWS gives this error sometimes.

code:

val fs = filePath.getFileSystem(spark.sparkContext.hadoopConfiguration)
val inputFromFile = fs.open(filePath)
def readLines = scala.io.Source.fromInputStream(inputFromFile)

Error: Exception in thread "main" java.nio.charset.MalformedInputException: Input length = 1

0

There are 0 best solutions below