Uploaded image for project: 'Kafka'
  1. Kafka
  2. KAFKA-9649

Remove/Warn on use of TimeWindowedSerde with no specified window size

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • None
    • 2.8.0
    • streams

    Description

      The API of the TimeWindowedSerde promotes its construction without specifying a window size:

      public TimeWindowedSerde(final Serde<T> inner)
      

      While code using this constructor looks absolutely clean, it leads to fatal errors at runtime, which turned out to be very hard to discover.

      The reason for these error can be found in the construction of the TimeWindowedDeserializer, which is created via:

      // TODO: fix this part as last bits of KAFKA-4468
      public TimeWindowedDeserializer(final Deserializer<T> inner) {
        this(inner, Long.MAX_VALUE);
      }
      

      The TODO comment suggests that this issue is (or at least was) already known.

      We suggest to either remove the TimeWindowedSerde(final Serde<T> inner) constructor or at least to warn when using it (if required for backwards compatiblity). The ideal solution of course would be to get the window size from some externally provided context. However, I expect this to be difficult to realize. Same applies also the TimeWindowedDeserializer(final Deserializer<T> inner) constructor.

      A further minor suggestion in this context: As now most Kafka Streams time declarations use Duration s instead of long-encoded milliseconds, I suggest to allow specifying window sizes with a Duration.

      Attachments

        Issue Links

          Activity

            People

              lthomas Leah Thomas
              SoerenHenning Sören Henning
              Votes:
              0 Vote for this issue
              Watchers:
              5 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: