Skip to content

Instantly share code, notes, and snippets.

@Rogach
Last active October 5, 2018 12:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Rogach/41a7331047026d7d392ec1581f4b620a to your computer and use it in GitHub Desktop.
Save Rogach/41a7331047026d7d392ec1581f4b620a to your computer and use it in GitHub Desktop.
scallop #137 bug
scalaVersion := "2.11.0"
libraryDependencies += "org.rogach" %% "scallop" % "3.1.2"
import org.rogach.scallop._
import java.io.{Serializable, ByteArrayOutputStream, ByteArrayInputStream, ObjectOutputStream, ObjectInputStream}
trait PropsArgument extends ScallopConf {
@transient val p: Map[String, String] = props[String]('D')
}
class TestConf(args: List[String]) extends ScallopConf(args) with Serialization with PropsArgument {
val apples = opt[Int]("apples")
verify()
}
class App(val conf: TestConf) extends Serializable {
val overrideMap: Map[String, String] = conf.p
}
object Test {
def main(args: Array[String]) {
val conf = new TestConf(List("-a","3","-Dkey=value"))
val app = new App(conf)
val bos = new ByteArrayOutputStream()
val out = new ObjectOutputStream(bos)
out.writeObject(app)
out.flush()
out.close()
val bytes = bos.toByteArray()
val bis = new ByteArrayInputStream(bytes);
val in = new ObjectInputStream(bis);
val app2 = in.readObject().asInstanceOf[App]
println(app2.conf.apples())
println(app2.conf.p)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment