This is an automated email from the ASF dual-hosted git repository.

junrao pushed a commit to branch trunk
in repository https://gitbox.apache.org/repos/asf/kafka.git


The following commit(s) were added to refs/heads/trunk by this push:
     new 47094ef  MINOR: Log constructor: Flip logical NOT for readability 
(#10756)
47094ef is described below

commit 47094ef7bbd248baa8deaf24cd7c6ff88e6498a6
Author: Kowshik Prakasam <[email protected]>
AuthorDate: Wed May 26 13:22:32 2021 -0700

    MINOR: Log constructor: Flip logical NOT for readability (#10756)
    
    Reviewers: Jun Rao <[email protected]>
---
 core/src/main/scala/kafka/log/Log.scala | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/core/src/main/scala/kafka/log/Log.scala 
b/core/src/main/scala/kafka/log/Log.scala
index 76b2b7e..82e083f 100644
--- a/core/src/main/scala/kafka/log/Log.scala
+++ b/core/src/main/scala/kafka/log/Log.scala
@@ -324,14 +324,14 @@ class Log(@volatile private var _dir: File,
     // write to the partition metadata file.
     // Ensure we do not try to assign a provided topicId that is inconsistent 
with the ID on file.
     if (partitionMetadataFile.exists()) {
-        if (!keepPartitionMetadataFile)
-          partitionMetadataFile.delete()
-        else {
+        if (keepPartitionMetadataFile) {
           val fileTopicId = partitionMetadataFile.read().topicId
           if (topicId.isDefined && !topicId.contains(fileTopicId))
             throw new InconsistentTopicIdException(s"Tried to assign topic ID 
$topicId to log for topic partition $topicPartition," +
               s"but log already contained topic ID $fileTopicId")
           topicId = Some(fileTopicId)
+        } else {
+          partitionMetadataFile.delete()
         }
     } else if (keepPartitionMetadataFile) {
       topicId.foreach(partitionMetadataFile.write)

Reply via email to