Skip to content

Commit

Permalink
MINOR: Using enums for auto.offset.reset configuration (apache#12077)
Browse files Browse the repository at this point in the history
Using enums instead of Strings for auto.offset.reset configuration

Reviewers: Divij Vaidya <[email protected]>, Luke Chen <[email protected]
  • Loading branch information
RivenSun2 authored Apr 24, 2022
1 parent e8c675e commit 2b64f1a
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import org.apache.kafka.common.metrics.Sensor;
import org.apache.kafka.common.requests.JoinGroupRequest;
import org.apache.kafka.common.serialization.Deserializer;
import org.apache.kafka.common.utils.Utils;

import java.util.Arrays;
import java.util.Collections;
Expand Down Expand Up @@ -451,8 +452,8 @@ public class ConsumerConfig extends AbstractConfig {
CommonClientConfigs.RETRY_BACKOFF_MS_DOC)
.define(AUTO_OFFSET_RESET_CONFIG,
Type.STRING,
"latest",
in("latest", "earliest", "none"),
OffsetResetStrategy.LATEST.toString(),
in(Utils.enumOptions(OffsetResetStrategy.class)),
Importance.MEDIUM,
AUTO_OFFSET_RESET_DOC)
.define(CHECK_CRCS_CONFIG,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,13 @@
*/
package org.apache.kafka.clients.consumer;

import java.util.Locale;

public enum OffsetResetStrategy {
LATEST, EARLIEST, NONE
LATEST, EARLIEST, NONE;

@Override
public String toString() {
return super.toString().toLowerCase(Locale.ROOT);
}
}

0 comments on commit 2b64f1a

Please sign in to comment.