Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

There is AvroRuntimeException when field is an Option of value class #191

Closed
liutaon opened this issue Apr 19, 2018 · 2 comments
Closed
Assignees
Labels
Milestone

Comments

@liutaon
Copy link

liutaon commented Apr 19, 2018

There is AvroRuntimeException when field is an Option of value class

import java.io.File
import com.sksamuel.avro4s._

final case class SN(value: String) extends AnyVal // it's ok when remove AnyVal
final case class SimpleUser(name: String, sn: Option[SN])

implicit val schema = AvroSchema[SimpleUser]
val out = AvroOutputStream.data[SimpleUser](new File("tmp.avro"))
out.write(SimpleUser("Tom", Some(SN("123"))))
Environments:
OS: macOS 10.13.4
Java: 1.8.0_161
Scala: 2.12.5
org.apache.avro.AvroRuntimeException: Not a record schema: "string"
  at org.apache.avro.generic.GenericData$Record.<init>(GenericData.java:181)
  at $anon$1$anon$apply$macro$458$1$$anon$2.apply(<console>:53)
  at $anon$1$anon$apply$macro$458$1$$anon$2.apply(<console>:53)
  at com.sksamuel.avro4s.LowPriorityToValue$$anon$2.apply(ToRecord.scala:30)
  at com.sksamuel.avro4s.LowPriorityToValue$$anon$2.apply(ToRecord.scala:29)
  at com.sksamuel.avro4s.ToValue$$anon$8.$anonfun$apply$5(ToRecord.scala:109)
  at scala.Option.map(Option.scala:146)
  at com.sksamuel.avro4s.ToValue$$anon$8.apply(ToRecord.scala:109)
  at com.sksamuel.avro4s.ToValue$$anon$8.apply(ToRecord.scala:108)
  at $anon$1.apply(<console>:53)
  at $anon$1.apply(<console>:53)
  at com.sksamuel.avro4s.AvroDataOutputStream.$anonfun$x$1$2(AvroOutputStream.scala:55)
  at com.sksamuel.avro4s.AvroDataOutputStream.$anonfun$x$1$2$adapted(AvroOutputStream.scala:54)
  at com.sksamuel.avro4s.AvroDataOutputStream.write(AvroOutputStream.scala:66)
  ... 36 elided
@ylabi
Copy link

ylabi commented Apr 30, 2018

@liutaon did you manage by any chance, to find a workaround for this ?

@sksamuel sksamuel added the bug label Aug 16, 2018
@sksamuel sksamuel added this to the 2.0 milestone Aug 16, 2018
@sksamuel sksamuel self-assigned this Sep 24, 2018
@sksamuel
Copy link
Owner

This is now fixed in the 2.0 pre release branch.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants