Admaing opened a new pull request, #349:
URL: https://github.com/apache/flink-connector-kafka/pull/349

   ## What is the purpose of the change
   
   Kafka 4.0 added `by_duration:<duration>` as a third `auto.offset.reset` 
strategy (KIP-1106). kafka-clients 4.2.0 accepts it, but `KafkaSourceBuilder` 
runs every configured value through `KafkaPropertiesUtil#getResetStrategy`, 
which only matches the deprecated `OffsetResetStrategy` enum, so building the 
source fails with:
   
   ```
   auto.offset.reset can not be set to by_duration:PT1H. Valid values: 
[latest,earliest,none]
   ```
   
   The same call also guards the dynamic source builder and both table 
factories.
   
   `by_duration` has no `OffsetResetStrategy` constant, and it cannot be 
normalized the way the other three values are: `OffsetResetStrategy#name()` 
carries no duration, and lower-casing the whole configured value (which the 
existing code does) corrupts the ISO-8601 duration.
   
   ## Brief change log
   
   - `KafkaPropertiesUtil`: add `isDurationBasedReset` (case-insensitive prefix 
match), `normalizeDurationBasedReset` (validates the duration with 
`Duration.parse` and canonicalizes only the prefix), and share the valid-values 
string used in error messages.
   - `KafkaSourceBuilder`: pass a duration based strategy through, skipping 
`getResetStrategy` and the `.name().toLowerCase()` rewrite.
   - `DynamicKafkaSourceBuilder`: skip the "opposing strategy" warning for 
duration based resets, since that warning compares positional strategies only.
   - `KafkaDynamicSource` / `DynamicKafkaTableSource`: for `group-offsets`, 
keep `OffsetResetStrategy.NONE` for the initializer and leave the property in 
the consumer config, since `OffsetsInitializer` cannot express a duration.
   
   ## Verifying this change
   
   - `KafkaSourceBuilderTest`: `by_duration:PT1H30M` builds and keeps the 
configured value untouched; `BY_DURATION:PT30M` is normalized to 
`by_duration:PT30M`; `by_duration:not-a-duration` fails the build with the 
connector's usual reset-strategy error. The first two fail before the change 
with the exception above.
   - `KafkaPropertiesUtilTest`: prefix detection edge cases, prefix-only 
normalization, and rejection of malformed durations (`PT1H30`, empty duration).
   - `KafkaSourceBuilderTest`, `DynamicKafkaSourceBuilderTest`, 
`KafkaPropertiesUtilTest`: 43 tests pass; `spotless:check` and 
`checkstyle:check` pass.
   
   ## Does this pull request potentially affect one of the following parts
   
   - Dependencies (does it add or upgrade a dependency): no
   - The public API, i.e., is any changed class annotated with 
`@Public(Evolving)`: no
   - The serializers: no
   - The runtime per-record code paths (performance sensitive): no
   - Anything that affects deployment or recovery, e.g., checkpointing, 
savepoint, upgrading flink and flink-connector-kafka versions: no, the 
configured value reaches Kafka unchanged except for prefix casing.
   - `./mvnw spotless:check`
   - `./mvnw checkstyle:check`
   
   ## Documentation
   
   - Does this pull request introduce a new feature? It accepts a strategy the 
underlying client already supports; no new configuration option is introduced.
   - If yes, how is the feature documented? The valid-values error message now 
lists `by_duration:<duration>`.
   
   ---
   
   **AI Disclosure**
   
   Prepared with AI assistance (DeepSeek Harness), including the code changes, 
tests and this description. I reviewed the change and ran the test, `spotless` 
and `checkstyle` commands above locally; the direction and the final patch are 
my own.
   


-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to