bbejeck commented on code in PR #18115: URL: https://github.com/apache/kafka/pull/18115#discussion_r1879083489
########## streams/src/main/java/org/apache/kafka/streams/Topology.java: ########## @@ -326,7 +327,7 @@ public synchronized Topology addSource(final AutoOffsetReset offsetReset, final Deserializer<?> keyDeserializer, final Deserializer<?> valueDeserializer, final String... topics) { - internalTopologyBuilder.addSource(offsetReset, name, null, keyDeserializer, valueDeserializer, topics); + internalTopologyBuilder.addSource(offsetReset == null ? null : new AutoOffsetResetInternal(offsetReset), name, null, keyDeserializer, valueDeserializer, topics); Review Comment: maybe refactor `offsetReset == null ? null : new AutoOffsetResetInternal(offsetReset)` into a method since it's used in several places. ########## streams/src/main/java/org/apache/kafka/streams/kstream/internals/AutoOffsetResetInternal.java: ########## @@ -0,0 +1,64 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.kafka.streams.kstream.internals; + +import org.apache.kafka.streams.AutoOffsetReset; +import org.apache.kafka.streams.Topology; + +import java.time.Duration; +import java.util.Objects; + +public class AutoOffsetResetInternal extends AutoOffsetReset { + final OffsetResetStrategy resetStrategy; + + public AutoOffsetResetInternal(final Topology.AutoOffsetReset offsetReset) { + Objects.requireNonNull(offsetReset, "AutoOffsetReset cannot be null"); + this.resetStrategy = offsetReset == Topology.AutoOffsetReset.EARLIEST + ? OffsetResetStrategy.EARLIEST + : OffsetResetStrategy.LATEST; + } + + public static AutoOffsetResetInternal earliest() { + return new AutoOffsetResetInternal(Topology.AutoOffsetReset.EARLIEST); + } + + public static AutoOffsetResetInternal latest() { + return new AutoOffsetResetInternal(Topology.AutoOffsetReset.LATEST); + } + + public OffsetResetStrategy offsetResetStrategy() { + return resetStrategy; + } + + public Duration duration() { + return null; Review Comment: why a plain `null` here? ########## streams/src/main/java/org/apache/kafka/streams/kstream/internals/OffsetResetStrategy.java: ########## @@ -0,0 +1,23 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.kafka.streams.kstream.internals; + +public enum OffsetResetStrategy { Review Comment: > Topology.AutoOffsetReset does only have EARLIEST and LATEST, but not NONE I'm guessing that was an oversight. But overall I'm in favor of adding a `NONE` option as I prefer to give users the option to be explicit. I also think re-using `AutoOffsetResetStrategy.StategyType` is a good thing to do, as we should align with clients behavior. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: jira-unsubscr...@kafka.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org