Uploaded image for project: 'Flink'
  1. Flink
  2. FLINK-16230

Use LinkedHashSet instead of HashSet for a deterministic order when testing serialization

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Reopened
    • Not a Priority
    • Resolution: Unresolved
    • None
    • None
    • Hide
      The specification about HashSet says "it makes no guarantees as to the iteration order of the set; in particular, it does not guarantee that the order will remain constant over time."
      The documentation here is for your reference:
      https://docs.oracle.com/javase/8/docs/api/java/util/HashSet.html
      Show
      The specification about HashSet says "it makes no guarantees as to the iteration order of the set; in particular, it does not guarantee that the order will remain constant over time." The documentation here is for your reference: https://docs.oracle.com/javase/8/docs/api/java/util/HashSet.html

    Description

      The test in org.apache.flink.api.java.typeutils.runtime.kryo.KryoGenericTypeSerializerTest.testJavaSet(KryoGenericTypeSerializerTest.java:59) may fail due to a different iteration order of HashSet. The test aims to check the serializer of HashSet. It will invokeĀ org.apache.flink.testutils.DeeplyEqualsChecker.deepEqualsIterable(DeeplyEqualsChecker.java:107), where theĀ iterator of HashSet is called. However, the HashSet makes no guarantee about the order it iterates, finally causing an assertion failure. The fix is to use LinkedHashSet to make the test more stable.

      Attachments

        Issue Links

          Activity

            People

              Unassigned Unassigned
              cpugputpu cpugputpu
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:

                Time Tracking

                  Estimated:
                  Original Estimate - Not Specified
                  Not Specified
                  Remaining:
                  Remaining Estimate - 0h
                  0h
                  Logged:
                  Time Spent - 0.5h
                  0.5h