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

DG-716 Upgrade to Avro 1.10.1 #1742

Merged
merged 1 commit into from Jan 15, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -22,6 +22,7 @@
import com.google.common.collect.ImmutableMap;
import io.confluent.kafka.schemaregistry.client.rest.entities.SchemaReference;
import java.util.Arrays;
import org.apache.avro.AvroRuntimeException;
import org.apache.avro.Schema;
import org.apache.avro.SchemaBuilder;
import org.apache.avro.generic.GenericData;
Expand Down Expand Up @@ -509,7 +510,12 @@ public void testKafkaAvroSerializerWithProjection() {
GenericData.Record decoderProjection = (GenericData.Record) obj;
assertEquals("testUser", decoderProjection.get("name").toString());
//Age field was hidden by projection
assertNull(decoderProjection.get("age"));
try {
decoderProjection.get("age");
fail("Getting invalid schema field should fail");
} catch (AvroRuntimeException e){
//this is expected
}

obj = avroDeserializer.deserialize(topic, bytes, User.getClassSchema());
assertTrue(
Expand All @@ -519,7 +525,12 @@ public void testKafkaAvroSerializerWithProjection() {
GenericData.Record deserializeProjection = (GenericData.Record) obj;
assertEquals("testUser", deserializeProjection.get("name").toString());
//Age field was hidden by projection
assertNull(deserializeProjection.get("age"));
try {
deserializeProjection.get("age");
fail("Getting invalid schema field should fail");
} catch (AvroRuntimeException e){
//this is expected
}
}

@Test
Expand Down Expand Up @@ -554,7 +565,12 @@ public void testKafkaAvroSerializerSupportsSchemaEvolution() throws IOException,
assertNotNull("Optional field should have a non-null default value", genericRecordV2.get(newOptionalField));

// In version 2 of the schema, the fieldToDelete field is gone
assertNull("Field was removed in schema V2 but is still present", genericRecordV2.get(fieldToDelete));
try {
genericRecordV2.get(fieldToDelete);
fail("Getting invalid schema field should fail");
} catch (AvroRuntimeException e){
//this is expected
}
}

@Test
Expand Down
Expand Up @@ -23,7 +23,6 @@
import org.apache.avro.SchemaValidationException;
import org.apache.avro.SchemaValidator;
import org.apache.avro.SchemaValidatorBuilder;
import org.apache.avro.Schemas;

import java.util.ArrayList;
import java.util.Collections;
Expand Down Expand Up @@ -152,7 +151,7 @@ public String canonicalString() {
Schema schemaRef = parser.parse(schema);
schemaRefs.add(schemaRef);
}
canonicalString = Schemas.toString(schemaObj, schemaRefs);
canonicalString = schemaObj.toString(schemaRefs, false);
}
return canonicalString;
}
Expand Down
53 changes: 0 additions & 53 deletions client/src/main/java/org/apache/avro/Schemas.java

This file was deleted.

Expand Up @@ -14,10 +14,6 @@
*/
package io.confluent.kafka.schemaregistry.utils;

import org.apache.avro.Protocol;
import org.apache.avro.Schema;
import org.apache.avro.Schemas;

import io.confluent.kafka.schemaregistry.avro.AvroSchema;
import io.confluent.kafka.schemaregistry.avro.AvroUtils;
import io.confluent.kafka.schemaregistry.client.rest.RestService;
Expand Down