[GitHub] [spark] LuciferYang commented on a diff in pull request #39732: [SPARK-42178][UI] Handle remaining null string values in ui protobuf serializer and add tests
LuciferYang commented on code in PR #39732: URL: https://github.com/apache/spark/pull/39732#discussion_r1086234357 ## core/src/test/scala/org/apache/spark/status/protobuf/KVStoreProtobufSerializerSuite.scala: ## @@ -31,6 +34,32 @@ import org.apache.spark.ui.scope.{RDDOperationEdge, RDDOperationNode} class KVStoreProtobufSerializerSuite extends SparkFunSuite { private val serializer = new KVStoreProtobufSerializer() + test("All the string fields must be optional to avoid NPE") { +val protoFile = getWorkspaceFilePath( + "core", "src", "main", "protobuf", "org", "apache", "spark", "status", "protobuf", + "store_types.proto") + +val containsStringRegex = "\\s*string .*" +val invalidDefinition = new mutable.ArrayBuffer[(String, Int)]() +var lineNumber = 1 +Source.fromFile(protoFile.toFile.getCanonicalPath).getLines().foreach { line => + if (line.matches(containsStringRegex)) { Review Comment: `org.apache.spark.util.Utils.tryWithResource` should be used to ensure`Source.fromFile(protoFile.toFile.getCanonicalPath)` is closed after use -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org - To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org For additional commands, e-mail: reviews-h...@spark.apache.org
[GitHub] [spark] LuciferYang commented on a diff in pull request #39732: [SPARK-42178][UI] Handle remaining null string values in ui protobuf serializer and add tests
LuciferYang commented on code in PR #39732: URL: https://github.com/apache/spark/pull/39732#discussion_r1086234357 ## core/src/test/scala/org/apache/spark/status/protobuf/KVStoreProtobufSerializerSuite.scala: ## @@ -31,6 +34,32 @@ import org.apache.spark.ui.scope.{RDDOperationEdge, RDDOperationNode} class KVStoreProtobufSerializerSuite extends SparkFunSuite { private val serializer = new KVStoreProtobufSerializer() + test("All the string fields must be optional to avoid NPE") { +val protoFile = getWorkspaceFilePath( + "core", "src", "main", "protobuf", "org", "apache", "spark", "status", "protobuf", + "store_types.proto") + +val containsStringRegex = "\\s*string .*" +val invalidDefinition = new mutable.ArrayBuffer[(String, Int)]() +var lineNumber = 1 +Source.fromFile(protoFile.toFile.getCanonicalPath).getLines().foreach { line => + if (line.matches(containsStringRegex)) { Review Comment: `org.apache.spark.util.Utils.tryWithResource` should be used to ensure`Source.fromFile(protoFile.toFile.getCanonicalPath)` is closed -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org - To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org For additional commands, e-mail: reviews-h...@spark.apache.org