简体   繁体   中英

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

I saw this scala bug report marked as fix. But their code is slightly difference.

I am currently using Scala 2.11, but their bug is fixed on 2.8.

Is this possibly a new bug? Or I am just using transient incorrectly?

使XFile可Serializable应该可以解决您的问题

object XFile extends Document with Serializable {

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM