Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,8 @@ class KryoSerializer(conf: SparkConf)
reg.registerClasses(kryo)
}
} catch {
case e: Exception => logError("Failed to run spark.kryo.registrator", e)
case e: Exception => throw
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you change this to

    // Allow the user to register their own classes by setting spark.kryo.registrator
    for (regCls <- registrator) {
      logDebug("Running user registrator: " + regCls)
      try {
        val reg = Class.forName(regCls, true, classLoader).newInstance()
          .asInstanceOf[KryoRegistrator]
        reg.registerClasses(kryo)
      } catch {
        case e: Exception => 
          throw new SparkException(s"Failed to invoke $regCls", e)
      }
    }

new SparkException("Failed to run spark.kryo.registrator", e)
}

// Register Chill's classes; we do this after our ranges and the user's own classes to let
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,16 @@ class KryoSerializerSuite extends FunSuite with SharedSparkContext {
.fold(new ClassWithoutNoArgConstructor(10))((t1, t2) => new ClassWithoutNoArgConstructor(t1.x + t2.x)).x
assert(10 + control.sum === result)
}

test("kryo with nonexistant custom registrator should fail") {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

small typo : nonexistent

import org.apache.spark.{SparkConf, SparkException}

val conf = new SparkConf(false)
conf.set("spark.kryo.registrator", "this.class.does.not.exist")

val thrown = intercept[SparkException](new KryoSerializer(conf).newInstance())
assert(thrown.getMessage.contains("Failed to run spark.kryo.registrator"))
}
}

class KryoSerializerResizableOutputSuite extends FunSuite {
Expand Down