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

Implicit TimeWindowedSerde creates Serde with null inner serializer

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • 2.3.0
    • 2.4.0
    • streams
    • None

    Description

      Serdes.scala contains an implicit def timeWindowedSerde as below:

       

      implicit def timeWindowedSerde[T]: WindowedSerdes.TimeWindowedSerde[T] = new WindowedSerdes.TimeWindowedSerde[T]()
      

      It creates a new TimeWindowedSerde without inner serializer, which is a bug. Even in WindowedSerdes.java it says that empty constructor is for reflection.

      // Default constructor needed for reflection object creation
      public TimeWindowedSerde() {
          super(new TimeWindowedSerializer<>(), new TimeWindowedDeserializer<>());
      }
      
      public TimeWindowedSerde(final Serde<T> inner) {
           super(new TimeWindowedSerializer<>(inner.serializer()), new TimeWindowedDeserializer<>(inner.deserializer()));
      }
      

      All above failes for me when I try to implicitly access the right Serde:

      private val twSerde = implicitly[TimeWindowedSerde[String]]
      

      and I have to create the object properly on my own

        private val twSerde = new WindowedSerdes.TimeWindowedSerde[String](implicitly[Serde[String]])
      

      it could be fixed with a proper call in Serdes.scala

        implicit def timeWindowedSerde[T](implicit tSerde: Serde[T]): WindowedSerdes.TimeWindowedSerde[T] =
          new WindowedSerdes.TimeWindowedSerde[T](tSerde)
      

      But maybe also the scope of the default constructor for TimeWindowedSerde should be changed?

      BR, Michał

      Attachments

        Issue Links

          Activity

            People

              atais Michał
              atais Michał
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: