[英]Is there a bug on Scala's @transient?
I have a code structure like the following. 我有如下代码结构。
trait Document {
def name: String
@transient lazy val formalName = "FORMAL " + name
}
object XFile extends Document {
override val name = "XFILE"
}
But spark is throwing an java.io.NotSerializableException
on XFile
但是星火在
XFile
上抛出java.io.NotSerializableException
I saw this scala bug report marked as fix. 我看到此scala错误报告标记为已修复。 But their code is slightly difference.
但是它们的代码略有不同。
I am currently using Scala 2.11, but their bug is fixed on 2.8. 我目前正在使用Scala 2.11,但其错误已在2.8上修复。
Is this possibly a new bug? 这可能是一个新错误吗? Or I am just using transient incorrectly?
还是我只是错误地使用了瞬态?
使XFile可Serializable
应该可以解决您的问题
object XFile extends Document with Serializable {
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.