kafka-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Ewen Cheslack-Postava (JIRA)" <j...@apache.org>
Subject [jira] [Resolved] (KAFKA-2884) Schema cache corruption in JsonConverter
Date Mon, 04 Jan 2016 20:22:40 GMT

     [ https://issues.apache.org/jira/browse/KAFKA-2884?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]

Ewen Cheslack-Postava resolved KAFKA-2884.
------------------------------------------
    Resolution: Duplicate

Oops, seems when KAFKA-3055 was filed we missed that we already had this instance of the bug.
Marking this one as duplicate since we already applied a patch with KAFKA-3055.

> Schema cache corruption in JsonConverter
> ----------------------------------------
>
>                 Key: KAFKA-2884
>                 URL: https://issues.apache.org/jira/browse/KAFKA-2884
>             Project: Kafka
>          Issue Type: Bug
>          Components: copycat
>    Affects Versions: 0.9.0.0
>         Environment: MacBook Pro 15'' mid-2014
> Mac OS X 10.11.1
>            Reporter: Juan Hernandez
>            Assignee: Ewen Cheslack-Postava
>
> There is an issue with the schema cache in the {{JsonConverter}} class when using Struct
types that corrupts its entries.
> The schema cache returns an schema object for a given field type which then gets modified
setting the field name.
> {code}
> ObjectNode fieldJsonSchema = asJsonSchema(field.schema());       fieldJsonSchema.put(JsonSchema.STRUCT_FIELD_NAME_FIELD_NAME,
field.name());
> {code}
> The same `fieldJsonSchema` object instance is returned for following fields (of the same
type) and the field name attribute ({{JsonSchema.STRUCT_FIELD_NAME_FIELD_NAME}}) is set overwritting
the previous value. This causes to serialize a corrupted schema in the message.
> {code:title=JsonConverter.java|borderStyle=solid}
> private ObjectNode asJsonSchema(Schema schema) {
>     if (schema == null)
>         return null;
>     ObjectNode cached = fromConnectSchemaCache.get(schema);
>     if (cached != null)
>         return cached;
>     // ....
>     case STRUCT:
>         jsonSchema = JsonNodeFactory.instance.objectNode().put(JsonSchema.SCHEMA_TYPE_FIELD_NAME,
JsonSchema.STRUCT_TYPE_NAME);
>         ArrayNode fields = JsonNodeFactory.instance.arrayNode();
>         for (Field field : schema.fields()) {
>             ObjectNode fieldJsonSchema = asJsonSchema(field.schema());
>             fieldJsonSchema.put(JsonSchema.STRUCT_FIELD_NAME_FIELD_NAME, field.name());
>             fields.add(fieldJsonSchema);
>         }
>         jsonSchema.set(JsonSchema.STRUCT_FIELDS_FIELD_NAME, fields);
>         break;
>     // ...
> }
> {code}



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Mime
View raw message