You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jira@kafka.apache.org by "liefke (via GitHub)" <gi...@apache.org> on 2023/03/22 07:10:43 UTC

[GitHub] [kafka] liefke commented on a diff in pull request #12763: KAFKA-14273: Kafka doesn't start with KRaft on Windows

liefke commented on code in PR #12763:
URL: https://github.com/apache/kafka/pull/12763#discussion_r1144318640


##########
raft/src/main/java/org/apache/kafka/raft/FileBasedStateStore.java:
##########
@@ -149,6 +149,7 @@ private void writeElectionStateToFile(final File stateFile, QuorumStateData stat
             writer.write(jsonState.toString());
             writer.flush();
             fileOutputStream.getFD().sync();
+            fileOutputStream.close();

Review Comment:
   I would move `Utils.atomicMoveWithFallback` out of the _try with resource_:
   ```
   	try {
   		try (FileOutputStream fileOutputStream = ...) {
   		         ...
   		}
   		Utils.atomicMoveWithFallback(temp.toPath(), file.toPath());
   	} catch (final IOException e) {
   ```
   
   That way neither a comment nor a duplicate close is needed.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: jira-unsubscribe@kafka.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org