You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@spark.apache.org by GitBox <gi...@apache.org> on 2019/04/15 05:27:06 UTC

[GitHub] [spark] WeichenXu123 commented on a change in pull request #24362: [SPARK-27454][ML][SQL] Spark image datasource fail when encounter some illegal images

WeichenXu123 commented on a change in pull request #24362: [SPARK-27454][ML][SQL] Spark image datasource fail when encounter some illegal images
URL: https://github.com/apache/spark/pull/24362#discussion_r275210103
 
 

 ##########
 File path: mllib/src/main/scala/org/apache/spark/ml/image/ImageSchema.scala
 ##########
 @@ -133,7 +133,13 @@ object ImageSchema {
    */
   private[spark] def decode(origin: String, bytes: Array[Byte]): Option[Row] = {
 
-    val img = ImageIO.read(new ByteArrayInputStream(bytes))
+    val img = try {
+      ImageIO.read(new ByteArrayInputStream(bytes))
+    } catch {
+      // Catch runtime exception because `ImageIO` may throw unexcepted `RuntimeException`.
+      // But do not catch the declared `IOException` (regarded as FileSystem failure)
+      case _: RuntimeException => null
 
 Review comment:
   I am afraid it will log too many things , suppose loading millions of images. (And when loading failed with `imageIO.read` normally return "null" we also do not log error.

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org