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

Using `equals` instead of `==` when Uuid compare in Java

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Resolved
    • Minor
    • Resolution: Fixed
    • None
    • 3.2.0, 3.1.1, 3.3.0
    • clients
    • None

    Description

      Uuid.ZERO_UUID == new Uuid(0L, 0L)

      is true in scala, but in java is false.

       

      So this test run sccessfully. Is this the expected situation??

      @Test
      public void testTopicIdAndNullTopicNameRequests() {
          // Construct invalid MetadataRequestTopics. We will build each one separately and ensure the error is thrown.
          List<MetadataRequestData.MetadataRequestTopic> topics = Arrays.asList(
                  new MetadataRequestData.MetadataRequestTopic().setName("topic").setTopicId(new Uuid(0L, 0L)));
      
          // if version is 10 or 11, the invalid topic metadata should return an error
          List<Short> invalidVersions = Arrays.asList((short) 10, (short) 11);
          invalidVersions.forEach(version ->
              topics.forEach(topic -> {
                  MetadataRequestData metadataRequestData = new MetadataRequestData().setTopics(Collections.singletonList(topic));
                  MetadataRequest.Builder builder = new MetadataRequest.Builder(metadataRequestData);
                  assertThrows(UnsupportedVersionException.class, () -> builder.build(version));
              })
          );
      }

      Attachments

        Issue Links

          Activity

            People

              Unassigned Unassigned
              fxbing Xiaobing Fang
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: