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

AvroGenerator fails on SpecificRecords compiled with String getters and Setters #715

Closed
clairemcginty opened this issue Feb 28, 2024 · 1 comment

Comments

@clairemcginty
Copy link
Contributor

AvroGenerator fails on SpecificRecords compiled with sbt-avro's avroStringType := "String" setting, which produces string field getters/setters with a java.lang.String signature (without this setting, string fields generate CharSequence getters/setters).

Sample repro here: https://github.com/spotify/ratatool/compare/avro-gen-stringtyped?expand=1

Produces the following exception:

[info] - should Support Avro types with String getters and setters *** FAILED ***
[info]   java.lang.ClassCastException: class org.apache.avro.util.Utf8 cannot be cast to class java.lang.String (org.apache.avro.util.Utf8 is in unnamed module of loader 'app'; java.lang.String is in module java.base of loader 'bootstrap')
[info]   at com.spotify.ratatool.scalacheck.TestStringTypedRecord.put(TestStringTypedRecord.java:83)
[info]   at com.spotify.ratatool.scalacheck.AvroGeneratorOps.$anonfun$avroValueOf$6(AvroGenerator.scala:102)
[info]   at scala.collection.LinearSeqOptimized.foldLeft(LinearSeqOptimized.scala:126)
[info]   at scala.collection.LinearSeqOptimized.foldLeft$(LinearSeqOptimized.scala:122)
[info]   at scala.collection.immutable.List.foldLeft(List.scala:91)
[info]   at com.spotify.ratatool.scalacheck.AvroGeneratorOps.$anonfun$avroValueOf$5(AvroGenerator.scala:100)
[info]   at scala.Option.map(Option.scala:230)
[info]   at org.scalacheck.Gen$R.map(Gen.scala:426)
[info]   at org.scalacheck.Gen$R.map$(Gen.scala:425)
[info]   at org.scalacheck.Gen$R$$anon$3.map(Gen.scala:419)

cc @RustedBones

@RustedBones
Copy link

Fixed in #709

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

No branches or pull requests

2 participants