jsancio commented on code in PR #14354: URL: https://github.com/apache/kafka/pull/14354#discussion_r1319056404
########## raft/src/main/java/org/apache/kafka/raft/FileBasedStateStore.java: ########## @@ -144,21 +144,29 @@ private void writeElectionStateToFile(final File stateFile, QuorumStateData stat log.trace("Writing tmp quorum state {}", temp.getAbsolutePath()); - try (final FileOutputStream fileOutputStream = new FileOutputStream(temp); - final BufferedWriter writer = new BufferedWriter( - new OutputStreamWriter(fileOutputStream, StandardCharsets.UTF_8))) { - short version = state.highestSupportedVersion(); - - ObjectNode jsonState = (ObjectNode) QuorumStateDataJsonConverter.write(state, version); - jsonState.set(DATA_VERSION, new ShortNode(version)); - writer.write(jsonState.toString()); - writer.flush(); - fileOutputStream.getFD().sync(); + try { + try (final FileOutputStream fileOutputStream = new FileOutputStream(temp); + final BufferedWriter writer = new BufferedWriter( + new OutputStreamWriter(fileOutputStream, StandardCharsets.UTF_8) + ) + ) { + short version = state.highestSupportedVersion(); Review Comment: Done. -- 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-unsubscr...@kafka.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org