sksamuel / avro4s

Avro schema generation and serialization / deserialization for Scala
Apache License 2.0
719 stars 238 forks source link

Facing issue to generate Schema for case class having a java construct in it. #856

Open chandan-kumar-ai opened 1 week ago

chandan-kumar-ai commented 1 week ago
test("Sample case class testing") {
    case class TestRecord(intField: Int, stringField: String, instant: Instant, doubleArray:  Array[java.lang.Double])
    val schema = AvroSchema[TestRecord]
    println(schema.toString(true))
  }

if change java.lang.Double to Double it works

Otherwise This generate error could not find implicit value for parameter schemaFor: com.sksamuel.avro4s.SchemaFor[TestRecord]
    val schema = AvroSchema[TestRecord]

if I add

implicit lazy val schemaFor: SchemaFor[TestRecord] = SchemaFor[TestRecord]

This ends with

java.lang.StackOverflowError

using avro4s 4.x version.