Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ It is intended that the application uses a certificate to expose its API and use
## Notice

* Compatible with **JDK 8, 11, 15, 16 and 17**
* Compatible with **schema-registry version 5.3.1 or later**
* Compatible with **avro version 1.9.1 or later**
* Compatible with **schema-registry version 7.1.3 or later**
* Compatible with **avro version 1.11.1 or later**

## 1. Quick Start

Expand Down Expand Up @@ -118,7 +118,7 @@ You can pull it from the central Maven repositories:
<dependency>
<groupId>com.github.mvallim</groupId>
<artifactId>spring-schema-registry</artifactId>
<version>2.1.0</version>
<version>2.2.0</version>
</dependency>
```

Expand All @@ -138,7 +138,7 @@ If you want to try a snapshot version, add the following repository:
#### Gradle

```groovy
implementation 'com.github.mvallim:spring-schema-registry:2.1.0'
implementation 'com.github.mvallim:spring-schema-registry:2.2.0'
```

If you want to try a snapshot version, add the following repository:
Expand Down
49 changes: 25 additions & 24 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

<groupId>com.github.mvallim</groupId>
<artifactId>spring-schema-registry</artifactId>
<version>2.1.1-SNAPSHOT</version>
<version>2.2.0-SNAPSHOT</version>
<packaging>jar</packaging>

<name>spring-schema-registry</name>
Expand All @@ -14,11 +14,11 @@
<java.version>1.8</java.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<schema.registry.version>5.3.1</schema.registry.version>
<schema.registry.version>7.1.3</schema.registry.version>
<commons.lang.version>3.12.0</commons.lang.version>
<spring.boot.version>2.2.13.RELEASE</spring.boot.version>
<avro.version>1.9.1</avro.version>
<lombok.version>1.18.20</lombok.version>
<spring.boot.version>2.7.2</spring.boot.version>
<avro.version>1.11.1</avro.version>
<lombok.version>1.18.24</lombok.version>
<commons-cli>1.4</commons-cli>
</properties>

Expand Down Expand Up @@ -67,6 +67,7 @@
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
<version>5.3.22</version>
</dependency>

<!-- Apache Commons -->
Expand All @@ -79,6 +80,7 @@
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>${lombok.version}</version>
<optional>true</optional>
</dependency>

Expand All @@ -99,33 +101,32 @@
</dependency>

<!-- Test -->

<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.hamcrest</groupId>
<artifactId>hamcrest-library</artifactId>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<version>5.9.0</version>
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.apache.kafka</groupId>
<artifactId>kafka_2.11</artifactId>
<artifactId>kafka_2.13</artifactId>
<version>3.1.1</version>
<scope>test</scope>
</dependency>

<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
<version>1.2.11</version>
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.assertj</groupId>
<artifactId>assertj-core</artifactId>
<version>3.23.1</version>
<scope>test</scope>
</dependency>
</dependencies>
Expand Down Expand Up @@ -204,7 +205,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.22.2</version>
<version>3.0.0-M7</version>
<configuration>
<useSystemClassLoader>false</useSystemClassLoader>
<argLine>${jacoco.argLine} -Dfile.encoding=${project.build.sourceEncoding}</argLine>
Expand All @@ -214,7 +215,7 @@
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>0.8.6</version>
<version>0.8.8</version>
<configuration>
<excludes>
<exclude>**/test/**</exclude>
Expand Down Expand Up @@ -245,14 +246,14 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-clean-plugin</artifactId>
<version>2.5</version>
<version>3.2.0</version>
<inherited>true</inherited>
</plugin>

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.7.0</version>
<version>3.10.1</version>
<configuration>
<source>${java.version}</source>
<target>${java.version}</target>
Expand All @@ -274,7 +275,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
<version>3.0.2</version>
<version>3.2.0</version>
<configuration>
<encoding>${project.build.sourceEncoding}</encoding>
</configuration>
Expand All @@ -283,7 +284,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
<version>2.2.1</version>
<version>3.2.1</version>
<inherited>true</inherited>
<executions>
<execution>
Expand All @@ -298,14 +299,14 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-install-plugin</artifactId>
<version>2.5.1</version>
<version>3.0.1</version>
<inherited>true</inherited>
</plugin>

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-deploy-plugin</artifactId>
<version>2.8.1</version>
<version>3.0.0</version>
<inherited>true</inherited>
<configuration>
<updateReleaseInfo>true</updateReleaseInfo>
Expand Down Expand Up @@ -394,7 +395,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
<version>2.2.1</version>
<version>3.2.1</version>
<executions>
<execution>
<phase>package</phase>
Expand All @@ -407,7 +408,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>2.9.1</version>
<version>3.3.2</version>
<executions>
<execution>
<phase>package</phase>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

import io.confluent.kafka.schemaregistry.avro.AvroSchema;
import org.apache.avro.Schema;
import org.apache.avro.generic.GenericDatumReader;
import org.apache.avro.generic.GenericRecord;
Expand Down Expand Up @@ -36,24 +37,24 @@ public GenericKafkaAvroDeserializer(final SchemaRegistryClient schemaRegistryCli

@Override
@SneakyThrows
protected Object deserialize(final boolean includeSchemaAndVersion, final String topic, final Boolean isKey, final byte[] payload, final Schema readerSchema) throws SerializationException {
protected Object deserialize(final String topic, final Boolean isKey, final byte[] payload, final Schema readerSchema) throws SerializationException {

final ByteBuffer buffer = ByteBuffer.wrap(payload);

if (buffer.get() != MAGIC_BYTE) {
throw new SerializationException("Unknown magic byte!");
}

final Schema schema = schemaRegistry.getById(buffer.getInt());
final AvroSchema schema = (AvroSchema)schemaRegistry.getSchemaById(buffer.getInt());

final String fullName = schema.getFullName();
final String fullName = schema.name();

if (constraintClass(fullName)) {
return super.deserialize(includeSchemaAndVersion, topic, isKey, payload, readerSchema);
return super.deserialize(topic, isKey, payload, readerSchema);
} else {
final int length = buffer.limit() - 1 - idSize;
final int start = buffer.position() + buffer.arrayOffset();
final DatumReader<GenericRecord> datumReader = new GenericDatumReader<>(schema);
final DatumReader<GenericRecord> datumReader = new GenericDatumReader<>(schema.rawSchema());
return datumReader.read(null, decoderFactory.binaryDecoder(buffer.array(), start, length, null));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@

import javax.net.ssl.SSLSocketFactory;

import io.confluent.kafka.serializers.AbstractKafkaSchemaSerDeConfig;
import org.apache.kafka.common.serialization.Deserializer;
import org.springframework.schemaregistry.core.SchemaRegistrySSLSocketFactory;

import io.confluent.kafka.schemaregistry.client.CachedSchemaRegistryClient;
import io.confluent.kafka.schemaregistry.client.SchemaRegistryClient;
import io.confluent.kafka.schemaregistry.client.rest.RestService;
import io.confluent.kafka.serializers.AbstractKafkaAvroSerDeConfig;
import io.confluent.kafka.serializers.KafkaAvroDeserializer;
import io.confluent.kafka.serializers.KafkaAvroDeserializerConfig;

Expand All @@ -34,7 +34,7 @@ public void configure(final Map<String, ?> configs, final boolean isKey) {

if (Objects.isNull(schemaRegistry)) {

final AbstractKafkaAvroSerDeConfig deserializerConfig = new KafkaAvroDeserializerConfig(configs);
final AbstractKafkaSchemaSerDeConfig deserializerConfig = new KafkaAvroDeserializerConfig(configs);

final RestService restService = new RestService(deserializerConfig.getSchemaRegistryUrls());

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@

import javax.net.ssl.SSLSocketFactory;

import io.confluent.kafka.serializers.AbstractKafkaSchemaSerDeConfig;
import org.apache.kafka.common.serialization.Serializer;
import org.springframework.schemaregistry.core.SchemaRegistrySSLSocketFactory;

import io.confluent.kafka.schemaregistry.client.CachedSchemaRegistryClient;
import io.confluent.kafka.schemaregistry.client.SchemaRegistryClient;
import io.confluent.kafka.schemaregistry.client.rest.RestService;
import io.confluent.kafka.serializers.AbstractKafkaAvroSerDeConfig;
import io.confluent.kafka.serializers.KafkaAvroSerializer;
import io.confluent.kafka.serializers.KafkaAvroSerializerConfig;

Expand All @@ -34,7 +34,7 @@ public void configure(final Map<String, ?> configs, final boolean isKey) {

if (Objects.isNull(schemaRegistry)) {

final AbstractKafkaAvroSerDeConfig serializerConfig = new KafkaAvroSerializerConfig(configs);
final AbstractKafkaSchemaSerDeConfig serializerConfig = new KafkaAvroSerializerConfig(configs);

final RestService restService = new RestService(serializerConfig.getSchemaRegistryUrls());

Expand Down
Loading