mirror of https://github.com/apache/kafka.git
KAFKA-15216: InternalSinkRecord::newRecord should not ignore new headers (#14044)
Reviewers: Chris Egerton <chrise@aiven.io>
This commit is contained in:
parent
35d4e9ec6e
commit
fd4759791f
|
@ -65,7 +65,7 @@ public class SinkRecord extends ConnectRecord<SinkRecord> {
|
|||
@Override
|
||||
public SinkRecord newRecord(String topic, Integer kafkaPartition, Schema keySchema, Object key, Schema valueSchema, Object value,
|
||||
Long timestamp, Iterable<Header> headers) {
|
||||
return new SinkRecord(topic, kafkaPartition, keySchema, key, valueSchema, value, kafkaOffset(), timestamp, timestampType, headers);
|
||||
return new SinkRecord(topic, kafkaPartition, keySchema, key, valueSchema, value, kafkaOffset, timestamp, timestampType, headers);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -14,7 +14,6 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.apache.kafka.connect.runtime;
|
||||
|
||||
import org.apache.kafka.clients.consumer.ConsumerRecord;
|
||||
|
@ -52,7 +51,7 @@ public class InternalSinkRecord extends SinkRecord {
|
|||
Schema valueSchema, Object value, Long timestamp,
|
||||
Iterable<Header> headers) {
|
||||
return new InternalSinkRecord(originalRecord, topic, kafkaPartition, keySchema, key,
|
||||
valueSchema, value, kafkaOffset(), timestamp, timestampType(), headers());
|
||||
valueSchema, value, kafkaOffset(), timestamp, timestampType(), headers);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -0,0 +1,44 @@
|
|||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.apache.kafka.connect.runtime;
|
||||
|
||||
import org.apache.kafka.clients.consumer.ConsumerRecord;
|
||||
import org.apache.kafka.connect.header.Header;
|
||||
import org.apache.kafka.connect.sink.SinkRecord;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.util.Collections;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.mockito.Mockito.mock;
|
||||
|
||||
public class InternalSinkRecordTest {
|
||||
|
||||
@Test
|
||||
public void testNewRecordHeaders() {
|
||||
SinkRecord sinkRecord = new SinkRecord("test-topic", 0, null, null, null, null, 10);
|
||||
ConsumerRecord<byte[], byte[]> consumerRecord = new ConsumerRecord<>("test-topic", 0, 10, null, null);
|
||||
InternalSinkRecord internalSinkRecord = new InternalSinkRecord(consumerRecord, sinkRecord);
|
||||
assertTrue(internalSinkRecord.headers().isEmpty());
|
||||
assertTrue(sinkRecord.headers().isEmpty());
|
||||
|
||||
SinkRecord newRecord = internalSinkRecord.newRecord("test-topic", 0, null, null, null,
|
||||
null, null, Collections.singletonList(mock(Header.class)));
|
||||
assertEquals(1, newRecord.headers().size());
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue