-
Notifications
You must be signed in to change notification settings - Fork 137
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fixes: #195 NoSuchFieldException when using consumer inherited from K…
…afkaConsumer Corrects use of reflection for field access, by using the KafkaConsumer class directly, instead of trying to find it from the provided consumer.
- Loading branch information
Showing
3 changed files
with
71 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
47 changes: 47 additions & 0 deletions
47
...-integration/java/io/confluent/parallelconsumer/integrationTests/CustomConsumersTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
package io.confluent.parallelconsumer.integrationTests; | ||
|
||
/*- | ||
* Copyright (C) 2020-2022 Confluent, Inc. | ||
*/ | ||
|
||
import io.confluent.parallelconsumer.ParallelConsumerOptions; | ||
import io.confluent.parallelconsumer.ParallelEoSStreamProcessor; | ||
import org.apache.kafka.clients.consumer.KafkaConsumer; | ||
import org.junit.jupiter.api.Test; | ||
|
||
import java.util.Properties; | ||
|
||
/** | ||
* @author Antony Stubbs | ||
*/ | ||
class CustomConsumersTest extends BrokerIntegrationTest { | ||
|
||
/** | ||
* Tests that extended consumer can be used with a custom consumer with PC. | ||
* <p> | ||
* Test for issue #195 - https://github.com/confluentinc/parallel-consumer/issues/195 | ||
* | ||
* @see io.confluent.parallelconsumer.internal.AbstractParallelEoSStreamProcessor#checkAutoCommitIsDisabled | ||
*/ | ||
@Test | ||
void extendedConsumer() { // NOSONAR | ||
Properties properties = getKcu().setupConsumerProps(this.getClass().getSimpleName()); | ||
CustomConsumer<String, String> client = new CustomConsumer<>(properties); | ||
|
||
ParallelConsumerOptions<String, String> options = ParallelConsumerOptions.<String, String>builder() | ||
.consumer(client) | ||
.build(); | ||
|
||
ParallelEoSStreamProcessor<String, String> pc = new ParallelEoSStreamProcessor<>(options); | ||
} | ||
|
||
static class CustomConsumer<K, V> extends KafkaConsumer<K, V> { | ||
|
||
String customField = "custom"; | ||
|
||
public CustomConsumer(Properties configs) { | ||
super(configs); | ||
} | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters