+ * Note that altering / resetting offsets is expected to be an idempotent operation and this method should be able
+ * to handle being called more than once with the same arguments (which could occur if a user retries the request
+ * due to a failure in altering the consumer group offsets, for example).
+ *
* Similar to {@link #validate(Map) validate}, this method may be called by the runtime before the
* {@link #start(Map) start} method is invoked.
*
* @param connectorConfig the configuration of the connector
* @param offsets a map from topic partition to offset, containing the offsets that the user has requested to
* alter/reset. For any topic partitions whose offsets are being reset instead of altered, their
- * corresponding value in the map will be {@code null}.
+ * corresponding value in the map will be {@code null}. This map may be empty, but never null. An
+ * empty offsets map could indicate that the offsets were reset previously or that no offsets have
+ * been committed yet.
* @return whether this method has been overridden by the connector; the default implementation returns
* {@code false}, and all other implementations (that do not unconditionally throw exceptions) should return
* {@code true}
* @throws UnsupportedOperationException if it is impossible to alter/reset the offsets for this connector
* @throws org.apache.kafka.connect.errors.ConnectException if the offsets for this connector cannot be
* reset for any other reason (for example, they have failed custom validation logic specific to this connector)
+ * @since 3.6
*/
public boolean alterOffsets(Map connectorConfig, Map offsets) {
return false;
diff --git a/connect/api/src/main/java/org/apache/kafka/connect/source/SourceConnector.java b/connect/api/src/main/java/org/apache/kafka/connect/source/SourceConnector.java
index eaaf56566c8..691476f77b0 100644
--- a/connect/api/src/main/java/org/apache/kafka/connect/source/SourceConnector.java
+++ b/connect/api/src/main/java/org/apache/kafka/connect/source/SourceConnector.java
@@ -85,19 +85,26 @@ public abstract class SourceConnector extends Connector {
* returned by any {@link org.apache.kafka.connect.storage.OffsetStorageReader OffsetStorageReader instances}
* provided to this connector and its tasks.
*
+ * Note that altering / resetting offsets is expected to be an idempotent operation and this method should be able
+ * to handle being called more than once with the same arguments (which could occur if a user retries the request
+ * due to a failure in writing the new offsets to the offsets store, for example).
+ *
* Similar to {@link #validate(Map) validate}, this method may be called by the runtime before the
* {@link #start(Map) start} method is invoked.
*
* @param connectorConfig the configuration of the connector
* @param offsets a map from source partition to source offset, containing the offsets that the user has requested
* to alter/reset. For any source partitions whose offsets are being reset instead of altered, their
- * corresponding source offset value in the map will be {@code null}
+ * corresponding source offset value in the map will be {@code null}. This map may be empty, but
+ * never null. An empty offsets map could indicate that the offsets were reset previously or that no
+ * offsets have been committed yet.
* @return whether this method has been overridden by the connector; the default implementation returns
* {@code false}, and all other implementations (that do not unconditionally throw exceptions) should return
* {@code true}
* @throws UnsupportedOperationException if it is impossible to alter/reset the offsets for this connector
* @throws org.apache.kafka.connect.errors.ConnectException if the offsets for this connector cannot be
* reset for any other reason (for example, they have failed custom validation logic specific to this connector)
+ * @since 3.6
*/
public boolean alterOffsets(Map connectorConfig, Map