Abdgali Yerkingaliyev created KAFKA-20177:
---------------------------------------------

             Summary: Handle malformed partition.metadata without 
NullPointerException
                 Key: KAFKA-20177
                 URL: https://issues.apache.org/jira/browse/KAFKA-20177
             Project: Kafka
          Issue Type: Bug
          Components: core
    Affects Versions: 4.3.0
            Reporter: Abdgali Yerkingaliyev


h3. Problem

`PartitionMetadataReadBuffer` can throw `NullPointerException` when 
`partition.metadata` is empty or truncated.
h3. In 
{{{}org.apache.kafka.storage.internals.checkpoint.PartitionMetadataReadBuffer.java{}}},
 parsing uses {{split(line)}} even when {{{}line == null{}}}.
This can bypass the expected malformed-file handling path and lead to less 
consistent error handling for partition metadata read failures.

 
h3. Expected behavior

Malformed {{partition.metadata}} should fail with a controlled {{IOException}} 
(malformed line / invalid topic id), not with {{{}NullPointerException{}}}.
h3. Proposed fix
 * Make parsing null-safe in {{{}PartitionMetadataReadBuffer{}}}.
 * Validate key/value lines explicitly ({{{}version{}}}, {{{}topic_id{}}}).
 * Convert malformed UUID parsing into {{IOException}} via existing 
malformed-line path.

h3. Tests
 * Add focused tests for:   - empty file   - missing {{topic_id}} line   - 
malformed UUID   - {{ZERO_UUID}}   - valid metadata file
 * Add integration-style check that malformed file read is surfaced as 
{{KafkaStorageException}} by {{{}PartitionMetadataFile.read(){}}}.

h3. Compatibility / Risk

Low risk. Behavior is only changed for malformed input; valid files are 
unaffected.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to