[ 
https://issues.apache.org/jira/browse/KAFKA-7277?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16576854#comment-16576854
 ] 

John Roesler commented on KAFKA-7277:
-------------------------------------

I recommend that we validate each duration argument using a class like this:
{noformat}
package org.apache.kafka.streams.kstream;

import java.time.Duration;

final class ApiUtils {
    private ApiUtils() {}

    static Duration validateMillisecondDuration(final Duration duration, final 
String valueName) {
        try {
            //noinspection ResultOfMethodCallIgnored
            duration.toMillis();
            return duration;
        } catch (final ArithmeticException e) {
            throw new IllegalArgumentException(
                valueName + " must be expressible in milliseconds (" + duration 
+ " is too big)",
                e
            );
        }
    }
}{noformat}
Otherwise, we will wind up throwing ArithmeticException randomly with little 
explanation.

> Migrate Streams API to Duration instead of longMs times
> -------------------------------------------------------
>
>                 Key: KAFKA-7277
>                 URL: https://issues.apache.org/jira/browse/KAFKA-7277
>             Project: Kafka
>          Issue Type: Improvement
>            Reporter: John Roesler
>            Priority: Major
>
> Right now Streams API unversally represents time as ms-since-unix-epoch.
> There's nothing wrong, per se, with this, but Duration is more ergonomic for 
> an API.
> What we don't want is to present a heterogeneous API, so we need to make sure 
> the whole Streams API is in terms of Duration.
>  
> Implementation note: Durations potentially worsen memory pressure and gc 
> performance, so internally, we will still use longMs as the representation. 



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Reply via email to