Source:
<code>private Object deserialize(byte[] payload) throws MessageDecoderException { try { ByteBuffer buffer = getByteBuffer(payload); int id = buffer.getInt(); Schema schema = schemaRegistry.getByID(id); if (schema == null) throw new IllegalStateException("Unknown schema id: " + id); logger.debug(schema.toString()); String subject = constructSubject(topic, schema, isNew); logger.debug("Subject = " + subject); <START> if (latestSchema == null) { <END> SchemaMetadata metadata = schemaRegistry.getLatestSchemaMetadata(subject); latestSchema = parser.parse(metadata.getSchema()); latestVersion = metadata.getVersion(); } int version = schemaRegistry.getVersion(subject, schema); if (version > latestVersion) { String errorMsg = String.format( "Producer schema is newer than the schema known to Camus"); throw new MessageDecoderException(errorMsg); } int length = buffer.limit() - 1 - idSize; if (schema.getType().equals(Schema.Type.BYTES)) { byte[] bytes = new byte[length]; buffer.get(bytes, 0, length); return bytes; } int start = buffer.position() + buffer.arrayOffset(); DatumReader<Object> reader = new GenericDatumReader<Object>(schema, latestSchema); Object object = reader.read(null, decoderFactory.binaryDecoder(buffer.array(), start, length, null)); if (schema.getType().equals(Schema.Type.STRING)) { object = ((Utf8) object).toString(); } return object; } catch (IOException ioe) { throw new MessageDecoderException("Error deserializing Avro message", ioe); } catch (RestClientException re) { throw new MessageDecoderException("Error deserializing Avro message", re); } }</code><technical_language>=></technical_language>

Target:
private Object deserialize(byte[] payload) throws MessageDecoderException { try { ByteBuffer buffer = getByteBuffer(payload); int id = buffer.getInt(); Schema schema = schemaRegistry.getByID(id); if (schema == null) throw new IllegalStateException("Unknown schema id: " + id); logger.debug("Schema = " + schema.toString()); String subject = constructSubject(topic, schema, isNew); logger.debug("Subject = " + subject); if (latestSchema == null) { SchemaMetadata metadata = schemaRegistry.getLatestSchemaMetadata(subject); latestSchema = parser.parse(metadata.getSchema()); latestVersion = metadata.getVersion(); } int version = schemaRegistry.getVersion(subject, schema); if (version > latestVersion) { String errorMsg = String.format( "Producer schema is newer than the schema known to Camus"); throw new MessageDecoderException(errorMsg); } int length = buffer.limit() - 1 - idSize; if (schema.getType().equals(Schema.Type.BYTES)) { byte[] bytes = new byte[length]; buffer.get(bytes, 0, length); return bytes; } int start = buffer.position() + buffer.arrayOffset(); DatumReader<Object> reader = new GenericDatumReader<Object>(schema, latestSchema); Object object = reader.read(null, decoderFactory.binaryDecoder(buffer.array(), start, length, null)); if (schema.getType().equals(Schema.Type.STRING)) { object = ((Utf8) object).toString(); } return object; } catch (IOException ioe) { throw new MessageDecoderException("Error deserializing Avro message", ioe); } catch (RestClientException re) { throw new MessageDecoderException("Error deserializing Avro message", re); } }