英文:
Serialization of UUID to string in Jackson Avro > 2.11.0
问题
我有一个具有UUID属性的对象,我想将其序列化为Avro模式中的字符串。Jackson 2.11引入了修复,以更有效地序列化UUIDs,自那以后我一直在收到以下错误:
Caused by: java.lang.ClassCastException: class [B cannot be cast to class java.lang.CharSequence ([B and java.lang.CharSequence are in module java.base of loader 'bootstrap')
at org.apache.avro.generic.GenericDatumWriter.writeString(GenericDatumWriter.java:323)
at org.apache.avro.generic.GenericDatumWriter.writeString(GenericDatumWriter.java:315)
at org.apache.avro.generic.GenericDatumWriter.writeWithoutConversion(GenericDatumWriter.java:150)
at com.fasterxml.jackson.dataformat.avro.ser.NonBSGenericDatumWriter.write(NonBSGenericDatumWriter.java:123)
at org.apache.avro.generic.GenericDatumWriter.writeField(GenericDatumWriter.java:206)
at org.apache.avro.generic.GenericDatumWriter.writeRecord(GenericDatumWriter.java:195)
at org.apache.avro.generic.GenericDatumWriter.writeWithoutConversion(GenericDatumWriter.java:130)
at com.fasterxml.jackson.dataformat.avro.ser.NonBSGenericDatumWriter.write(NonBSGenericDatumWriter.java:123)
at org.apache.avro.generic.GenericDatumWriter.write(GenericDatumWriter.java:72)
at com.fasterxml.jackson.dataformat.avro.ser.RootContext.complete(RootContext.java:122)
at com.fasterxml.jackson.dataformat.avro.AvroGenerator._complete(AvroGenerator.java:621)
at com.fasterxml.jackson.dataformat.avro.AvroGenerator.writeEndObject(AvroGenerator.java:410)
at com.fasterxml.jackson.databind.ser.BeanSerializer.serialize(BeanSerializer.java:180)
at com.fasterxml.jackson.databind.ser.DefaultSerializerProvider._serialize(DefaultSerializerProvider.java:480)
有没有办法切换回以前的行为?我们不想改变Avro模式,只是为了升级Jackson。
英文:
I have object with UUID property and I want to serialize it to String in Avro schema. Jackson 2.11 introduced fix to serialize UUIDs more effectively and since then I am getting
Caused by: java.lang.ClassCastException: class [B cannot be cast to class java.lang.CharSequence ([B and java.lang.CharSequence are in module java.base of loader 'bootstrap')
at org.apache.avro.generic.GenericDatumWriter.writeString(GenericDatumWriter.java:323)
at org.apache.avro.generic.GenericDatumWriter.writeString(GenericDatumWriter.java:315)
at org.apache.avro.generic.GenericDatumWriter.writeWithoutConversion(GenericDatumWriter.java:150)
at com.fasterxml.jackson.dataformat.avro.ser.NonBSGenericDatumWriter.write(NonBSGenericDatumWriter.java:123)
at org.apache.avro.generic.GenericDatumWriter.writeField(GenericDatumWriter.java:206)
at org.apache.avro.generic.GenericDatumWriter.writeRecord(GenericDatumWriter.java:195)
at org.apache.avro.generic.GenericDatumWriter.writeWithoutConversion(GenericDatumWriter.java:130)
at com.fasterxml.jackson.dataformat.avro.ser.NonBSGenericDatumWriter.write(NonBSGenericDatumWriter.java:123)
at org.apache.avro.generic.GenericDatumWriter.write(GenericDatumWriter.java:72)
at com.fasterxml.jackson.dataformat.avro.ser.RootContext.complete(RootContext.java:122)
at com.fasterxml.jackson.dataformat.avro.AvroGenerator._complete(AvroGenerator.java:621)
at com.fasterxml.jackson.dataformat.avro.AvroGenerator.writeEndObject(AvroGenerator.java:410)
at com.fasterxml.jackson.databind.ser.BeanSerializer.serialize(BeanSerializer.java:180)
at com.fasterxml.jackson.databind.ser.DefaultSerializerProvider._serialize(DefaultSerializerProvider.java:480)
Is there any way to switch to previous behavior? We do not want to change Avro schema just to be able to upgrade Jackson.
答案1
得分: 0
这实际上是一个在这里修复的错误:https://github.com/FasterXML/jackson-databind/issues/2815
英文:
It is actually a bug fixed here https://github.com/FasterXML/jackson-databind/issues/2815
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论