11/*
2- * Copyright 2017 the original author or authors.
2+ * Copyright 2017-2018 the original author or authors.
33 *
44 * Licensed under the Apache License, Version 2.0 (the "License");
55 * you may not use this file except in compliance with the License.
2323import org .apache .kafka .common .TopicPartition ;
2424
2525/**
26- * A rebalance listener that provides access to the consumer object.
26+ * A rebalance listener that provides access to the consumer object. Starting with version
27+ * 2.1.5, as a convenience, default no-op implementations are provided for all methods,
28+ * allowing the user to implement just those (s)he is interested in.
2729 *
2830 * @author Gary Russell
2931 * @since 2.0
@@ -37,23 +39,29 @@ public interface ConsumerAwareRebalanceListener extends ConsumerRebalanceListene
3739 * @param consumer the consumer.
3840 * @param partitions the partitions.
3941 */
40- void onPartitionsRevokedBeforeCommit (Consumer <?, ?> consumer , Collection <TopicPartition > partitions );
42+ default void onPartitionsRevokedBeforeCommit (Consumer <?, ?> consumer , Collection <TopicPartition > partitions ) {
43+ // do nothing
44+ }
4145
4246 /**
4347 * The same as {@link #onPartitionsRevoked(Collection)} with the additional consumer
4448 * parameter. It is invoked by the container after any pending offsets are committed.
4549 * @param consumer the consumer.
4650 * @param partitions the partitions.
4751 */
48- void onPartitionsRevokedAfterCommit (Consumer <?, ?> consumer , Collection <TopicPartition > partitions );
52+ default void onPartitionsRevokedAfterCommit (Consumer <?, ?> consumer , Collection <TopicPartition > partitions ) {
53+ // do nothing
54+ }
4955
5056 /**
5157 * The same as {@link #onPartitionsAssigned(Collection)} with the additional consumer
5258 * parameter.
5359 * @param consumer the consumer.
5460 * @param partitions the partitions.
5561 */
56- void onPartitionsAssigned (Consumer <?, ?> consumer , Collection <TopicPartition > partitions );
62+ default void onPartitionsAssigned (Consumer <?, ?> consumer , Collection <TopicPartition > partitions ) {
63+ // do nothing
64+ }
5765
5866 @ Override
5967 default void onPartitionsRevoked (Collection <TopicPartition > partitions ) {
0 commit comments