Skip to content
Merged
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 @@ -33,11 +33,12 @@
public class AutoProduceBytesSchema<T> implements Schema<byte[]> {

@Setter
private boolean requireSchemaValidation = true;
private Schema<T> schema;
private boolean userProvidedSchema;
private volatile boolean requireSchemaValidation = true;
private volatile Schema<T> schema;
private final boolean userProvidedSchema;

public AutoProduceBytesSchema() {
this.userProvidedSchema = false;
}

public AutoProduceBytesSchema(Schema<T> schema) {
Expand Down Expand Up @@ -81,11 +82,12 @@ public byte[] encode(byte[] message) {

if (requireSchemaValidation) {
// verify if the message can be decoded by the underlying schema
if (schema instanceof KeyValueSchema
&& ((KeyValueSchema) schema).getKeyValueEncodingType().equals(KeyValueEncodingType.SEPARATED)) {
((KeyValueSchema) schema).getValueSchema().validate(message);
Schema<T> localSchema = schema;
if (localSchema instanceof KeyValueSchema && ((KeyValueSchema) localSchema).getKeyValueEncodingType()
.equals(KeyValueEncodingType.SEPARATED)) {
((KeyValueSchema) localSchema).getValueSchema().validate(message);
} else {
schema.validate(message);
localSchema.validate(message);
}
}

Expand Down
Loading