[MINOR] fix potential npe in spark writer (#6363)

Co-authored-by: zhanshaoxiong <shaoxiong0001@@gmail.com>
diff --git a/hudi-spark-datasource/hudi-spark-common/src/main/scala/org/apache/hudi/HoodieSparkSqlWriter.scala b/hudi-spark-datasource/hudi-spark-common/src/main/scala/org/apache/hudi/HoodieSparkSqlWriter.scala
index 1670018..c070248 100644
--- a/hudi-spark-datasource/hudi-spark-common/src/main/scala/org/apache/hudi/HoodieSparkSqlWriter.scala
+++ b/hudi-spark-datasource/hudi-spark-common/src/main/scala/org/apache/hudi/HoodieSparkSqlWriter.scala
@@ -809,9 +809,9 @@
   }
 
   private def extractConfigsRelatedToTimestampBasedKeyGenerator(keyGenerator: String,
-      params: Map[String, String]): Map[String, String] = {
-    if (keyGenerator.equals(classOf[TimestampBasedKeyGenerator].getCanonicalName) ||
-        keyGenerator.equals(classOf[TimestampBasedAvroKeyGenerator].getCanonicalName)) {
+                                                                params: Map[String, String]): Map[String, String] = {
+    if (classOf[TimestampBasedKeyGenerator].getCanonicalName.equals(keyGenerator) ||
+      classOf[TimestampBasedAvroKeyGenerator].getCanonicalName.equals(keyGenerator)) {
       params.filterKeys(HoodieTableConfig.PERSISTED_CONFIG_LIST.contains)
     } else {
       Map.empty