From daa277b06772f2408895a01bf19c0aa09a4f177d Mon Sep 17 00:00:00 2001 From: Mark Payne Date: Tue, 2 May 2017 16:59:42 -0400 Subject: [PATCH] NIFI-3775: This closes #1735. Ensure that a '0' byte is written out to Hortonworks Encoded Schema Reference header to indicate that GenericRecord is being used Signed-off-by: joewitt --- .../access/HortonworksEncodedSchemaReferenceStrategy.java | 2 +- .../schema/access/HortonworksEncodedSchemaReferenceWriter.java | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/nifi-nar-bundles/nifi-extension-utils/nifi-record-utils/nifi-standard-record-utils/src/main/java/org/apache/nifi/schema/access/HortonworksEncodedSchemaReferenceStrategy.java b/nifi-nar-bundles/nifi-extension-utils/nifi-record-utils/nifi-standard-record-utils/src/main/java/org/apache/nifi/schema/access/HortonworksEncodedSchemaReferenceStrategy.java index de89900c28..27bf16f306 100644 --- a/nifi-nar-bundles/nifi-extension-utils/nifi-record-utils/nifi-standard-record-utils/src/main/java/org/apache/nifi/schema/access/HortonworksEncodedSchemaReferenceStrategy.java +++ b/nifi-nar-bundles/nifi-extension-utils/nifi-record-utils/nifi-standard-record-utils/src/main/java/org/apache/nifi/schema/access/HortonworksEncodedSchemaReferenceStrategy.java @@ -46,7 +46,7 @@ public class HortonworksEncodedSchemaReferenceStrategy implements SchemaAccessSt @Override public RecordSchema getSchema(final FlowFile flowFile, final InputStream contentStream) throws SchemaNotFoundException, IOException { - final byte[] buffer = new byte[13]; + final byte[] buffer = new byte[14]; try { StreamUtils.fillBuffer(contentStream, buffer); } catch (final IOException ioe) { diff --git a/nifi-nar-bundles/nifi-extension-utils/nifi-record-utils/nifi-standard-record-utils/src/main/java/org/apache/nifi/schema/access/HortonworksEncodedSchemaReferenceWriter.java b/nifi-nar-bundles/nifi-extension-utils/nifi-record-utils/nifi-standard-record-utils/src/main/java/org/apache/nifi/schema/access/HortonworksEncodedSchemaReferenceWriter.java index bf6a9ea123..2e3e602a08 100644 --- a/nifi-nar-bundles/nifi-extension-utils/nifi-record-utils/nifi-standard-record-utils/src/main/java/org/apache/nifi/schema/access/HortonworksEncodedSchemaReferenceWriter.java +++ b/nifi-nar-bundles/nifi-extension-utils/nifi-record-utils/nifi-standard-record-utils/src/main/java/org/apache/nifi/schema/access/HortonworksEncodedSchemaReferenceWriter.java @@ -43,10 +43,11 @@ public class HortonworksEncodedSchemaReferenceWriter implements SchemaAccessWrit // This decoding follows the pattern that is provided for serializing data by the Hortonworks Schema Registry serializer // as it is provided at: // https://github.com/hortonworks/registry/blob/master/schema-registry/serdes/src/main/java/com/hortonworks/registries/schemaregistry/serdes/avro/AvroSnapshotSerializer.java - final ByteBuffer bb = ByteBuffer.allocate(13); + final ByteBuffer bb = ByteBuffer.allocate(14); bb.put((byte) LATEST_PROTOCOL_VERSION); bb.putLong(id); bb.putInt(version); + bb.put((byte) 0); // We always use generic records out.write(bb.array()); }