Skip to content

Commit

Permalink
fix: #99 Don't allow use of core methods from the vert.x module
Browse files Browse the repository at this point in the history
The threading system for the vert.x module is not compatible with the core module. Use the core module directly instead.
  • Loading branch information
astubbs committed Jul 23, 2021
1 parent 1c908fd commit 1411d5b
Showing 1 changed file with 31 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import lombok.SneakyThrows;
import lombok.extern.slf4j.Slf4j;
import org.apache.kafka.clients.consumer.ConsumerRecord;
import org.apache.kafka.clients.producer.ProducerRecord;
import org.apache.kafka.common.utils.Time;
import pl.tlinkowski.unij.api.UniLists;
import pl.tlinkowski.unij.api.UniMaps;
Expand Down Expand Up @@ -282,4 +283,34 @@ public void close(Duration timeout, DrainingMode drainMode) {
}
}

@Override
public void poll(Consumer<ConsumerRecord<K, V>> usersVoidConsumptionFunction) {
blockInvalidCoreMethodUse();
}

private void blockInvalidCoreMethodUse() {
throw new IllegalStateException("Can't use core methods from vert.x module. \n" +
"Throwing an exception here is ATM easier then doing the full vert.s base class refactor (https://github.com/confluentinc/parallel-consumer/pull/133) \n" +
"Use the core module directly instead. See https://github.com/confluentinc/parallel-consumer/issues/99");
}

@Override
public void pollAndProduceMany(Function<ConsumerRecord<K, V>, List<ProducerRecord<K, V>>> userFunction, Consumer<ConsumeProduceResult<K, V, K, V>> callback) {
blockInvalidCoreMethodUse();
}

@Override
public void pollAndProduceMany(Function<ConsumerRecord<K, V>, List<ProducerRecord<K, V>>> userFunction) {
blockInvalidCoreMethodUse();
}

@Override
public void pollAndProduce(Function<ConsumerRecord<K, V>, ProducerRecord<K, V>> userFunction) {
blockInvalidCoreMethodUse();
}

@Override
public void pollAndProduce(Function<ConsumerRecord<K, V>, ProducerRecord<K, V>> userFunction, Consumer<ConsumeProduceResult<K, V, K, V>> callback) {
blockInvalidCoreMethodUse();
}
}

0 comments on commit 1411d5b

Please sign in to comment.