Uploaded image for project: 'Beam'
  1. Beam
  2. BEAM-9042

AvroUtils.schemaCoder(schema) produces a not serializable SchemaCoder

Details

    • Bug
    • Status: Triage Needed
    • P2
    • Resolution: Fixed
    • 2.18.0
    • 2.18.0
    • sdk-java-core

    Description

      After some recent change in the implementation of AvroUtils.schemaCoder(schema) the produced SchemaCoder is not serializable.

      You can reproduce this by doing this:

      final SchemaCoder<GenericRecord> avroSchemaCoder = AvroUtils.schemaCoder(schema);
      CoderProperties.coderSerializable(avroSchemaCoder);

      it produces this exception

      unable to serialize SchemaCoder<Schema: Fields:
      Field{name=bool, description=, type=FieldType{typeName=BOOLEAN, nullable=false, logicalType=null, collectionElementType=null, mapKeyType=null, mapValueType=null, rowSchema=null, metadata={}}}
      Field{name=int, description=, type=FieldType{typeName=INT32, nullable=false, logicalType=null, collectionElementType=null, mapKeyType=null, mapValueType=null, rowSchema=null, metadata={}}}
       UUID: 6a1ff5b7-e3be-42c3-9b36-f8b53d487fcd delegateCoder: org.apache.beam.sdk.coders.Coder$ByteBuddy$LzAYzILR@5f8ca63c
      java.lang.IllegalArgumentException: unable to serialize SchemaCoder<Schema: Fields:
      Field{name=bool, description=, type=FieldType{typeName=BOOLEAN, nullable=false, logicalType=null, collectionElementType=null, mapKeyType=null, mapValueType=null, rowSchema=null, metadata={}}}
      Field{name=int, description=, type=FieldType{typeName=INT32, nullable=false, logicalType=null, collectionElementType=null, mapKeyType=null, mapValueType=null, rowSchema=null, metadata={}}}
       UUID: 6a1ff5b7-e3be-42c3-9b36-f8b53d487fcd delegateCoder: org.apache.beam.sdk.coders.Coder$ByteBuddy$LzAYzILR@5f8ca63c
       at org.apache.beam.sdk.util.SerializableUtils.serializeToByteArray(SerializableUtils.java:55)
       at org.apache.beam.sdk.util.SerializableUtils.clone(SerializableUtils.java:113)
       at org.apache.beam.sdk.util.SerializableUtils.ensureSerializable(SerializableUtils.java:92)
       at org.apache.beam.sdk.util.SerializableUtils.ensureSerializable(SerializableUtils.java:131)
       at org.apache.beam.sdk.testing.CoderProperties.coderSerializable(CoderProperties.java:181)
       at org.apache.beam.sdk.schemas.utils.AvroUtilsTest.testAvroSchemaCoders(AvroUtilsTest.java:543)
       at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
       at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
       at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
       at java.lang.reflect.Method.invoke(Method.java:498)
       at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:59)
       at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
       at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:56)
       at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
       at org.junit.runners.ParentRunner$3.evaluate(ParentRunner.java:305)
       at org.junit.runners.BlockJUnit4ClassRunner$1.evaluate(BlockJUnit4ClassRunner.java:100)
       at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:365)
       at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:103)
       at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:63)
       at org.junit.runners.ParentRunner$4.run(ParentRunner.java:330)
       at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:78)
       at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:328)
       at org.junit.runners.ParentRunner.access$100(ParentRunner.java:65)
       at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:292)
       at org.junit.runners.ParentRunner$3.evaluate(ParentRunner.java:305)
       at org.junit.runners.ParentRunner.run(ParentRunner.java:412)
       at org.gradle.api.internal.tasks.testing.junit.JUnitTestClassExecutor.runTestClass(JUnitTestClassExecutor.java:110)
       at org.gradle.api.internal.tasks.testing.junit.JUnitTestClassExecutor.execute(JUnitTestClassExecutor.java:58)
       at org.gradle.api.internal.tasks.testing.junit.JUnitTestClassExecutor.execute(JUnitTestClassExecutor.java:38)
       at org.gradle.api.internal.tasks.testing.junit.AbstractJUnitTestClassProcessor.processTestClass(AbstractJUnitTestClassProcessor.java:62)
       at org.gradle.api.internal.tasks.testing.SuiteTestClassProcessor.processTestClass(SuiteTestClassProcessor.java:51)
       at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
       at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
       at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
       at java.lang.reflect.Method.invoke(Method.java:498)
       at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:35)
       at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:24)
       at org.gradle.internal.dispatch.ContextClassLoaderDispatch.dispatch(ContextClassLoaderDispatch.java:32)
       at org.gradle.internal.dispatch.ProxyDispatchAdapter$DispatchingInvocationHandler.invoke(ProxyDispatchAdapter.java:93)
       at com.sun.proxy.$Proxy2.processTestClass(Unknown Source)
       at org.gradle.api.internal.tasks.testing.worker.TestWorker.processTestClass(TestWorker.java:118)
       at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
       at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
       at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
       at java.lang.reflect.Method.invoke(Method.java:498)
       at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:35)
       at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:24)
       at org.gradle.internal.remote.internal.hub.MessageHubBackedObjectConnection$DispatchWrapper.dispatch(MessageHubBackedObjectConnection.java:175)
       at org.gradle.internal.remote.internal.hub.MessageHubBackedObjectConnection$DispatchWrapper.dispatch(MessageHubBackedObjectConnection.java:157)
       at org.gradle.internal.remote.internal.hub.MessageHub$Handler.run(MessageHub.java:404)
       at org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.java:63)
       at org.gradle.internal.concurrent.ManagedExecutorImpl$1.run(ManagedExecutorImpl.java:46)
       at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
       at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
       at org.gradle.internal.concurrent.ThreadFactoryImpl$ManagedThreadRunnable.run(ThreadFactoryImpl.java:55)
       at java.lang.Thread.run(Thread.java:748)
      Caused by: java.io.NotSerializableException: org.apache.avro.Schema$RecordSchema
       at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1184)
       at java.io.ObjectOutputStream.writeArray(ObjectOutputStream.java:1378)
       at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1174)

       

      Attachments

        Activity

          People

            iemejia Ismaël Mejía
            iemejia Ismaël Mejía
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: