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

ReassignPartitionsCommand#parsePartitionReassignmentData() should give better error message when JSON is malformed

    XMLWordPrintableJSON

    Details

    • Type: Improvement
    • Status: Resolved
    • Priority: Minor
    • Resolution: Duplicate
    • Affects Version/s: None
    • Fix Version/s: None
    • Component/s: None
    • Labels:

      Description

      In this thread: http://search-hadoop.com/m/Kafka/uyzND1J9Hizcxo0X?subj=Partition+reassignment+data+file+is+empty , Allen gave an example JSON string with extra comma where partitionsToBeReassigned returned by ReassignPartitionsCommand#parsePartitionReassignmentData() was empty.

      I tried the following example where a right bracket is removed:

          val (partitionsToBeReassigned, replicaAssignment) = ReassignPartitionsCommand.parsePartitionReassignmentData(
              "{\"version\":1,\"partitions\":[{\"topic\":\"metrics\",\"partition\":0,\"replicas\":[1,2]},{\"topic\":\"metrics\",\"partition\":1,\"replicas\":[2,3]},}");
      

      The returned partitionsToBeReassigned is empty (and no exception was thrown).

      The parser should give better error message for malformed JSON string.

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                Unassigned
                Reporter:
                yuzhihong@gmail.com Ted Yu
              • Votes:
                0 Vote for this issue
                Watchers:
                2 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: