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

[Snyk] Security upgrade org.apache.kafka:kafka-streams from 3.6.2 to 3.7.0 #1

Closed
Closed
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
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
* =========================LICENSE_END==================================
*/

import com.google.common.collect.ImmutableMap;
import io.axual.ksml.data.exception.DataException;
import io.axual.ksml.data.exception.ExecutionException;
import io.axual.ksml.data.mapper.NativeDataObjectMapper;
Expand All @@ -40,15 +41,13 @@ public class AvroNotation implements Notation {
public static final DataType DEFAULT_TYPE = new StructType();
private static final AvroDataObjectMapper mapper = new AvroDataObjectMapper();
private final NativeDataObjectMapper nativeMapper;
private final Serde<Object> keySerde;
private final Serde<Object> valueSerde;
private final Map<String, ?> serdeConfigs;
private Serde<Object> keySerde;
private Serde<Object> valueSerde;

public AvroNotation(NativeDataObjectMapper nativeMapper, Map<String, ?> configs) {
this.nativeMapper = nativeMapper;
keySerde = new AvroSerde();
keySerde.configure(configs, true);
valueSerde = new AvroSerde();
valueSerde.configure(configs, false);
this.serdeConfigs = ImmutableMap.copyOf(configs);
}

@Override
Expand All @@ -58,8 +57,18 @@ public String name() {

@Override
public Serde<Object> serde(DataType type, boolean isKey) {
if (type instanceof MapType) return isKey ? keySerde : valueSerde;
throw new DataException("Avro serde not found for data type " + type);
if (!(type instanceof MapType)) throw new DataException("AVRO serde can not be applied to type " + type);

// Create the serdes only upon request to prevent error messages on missing SR url configs if AVRO is not used
if (keySerde == null) {
keySerde = new AvroSerde();
keySerde.configure(serdeConfigs, true);
}
if (valueSerde == null) {
valueSerde = new AvroSerde();
valueSerde.configure(serdeConfigs, false);
}
return isKey ? keySerde : valueSerde;
}

private class AvroSerde implements Serde<Object> {
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@
<apache.avro.version>1.11.3</apache.avro.version>
<apache.commons.text.version>1.12.0</apache.commons.text.version>
<apache.commons.compress.version>1.26.2</apache.commons.compress.version>
<apache.kafka.version>3.6.2</apache.kafka.version>
<apache.kafka.version>3.7.0</apache.kafka.version>
<confluent.version>7.6.1</confluent.version>
<graalvm.version>23.1.2</graalvm.version>
<graalvm.polyglot.version>23.1.2</graalvm.polyglot.version>
Expand Down
Loading