cmccabe commented on code in PR #14354: URL: https://github.com/apache/kafka/pull/14354#discussion_r1319034514
########## 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: while we're fixing this let's get rid of `highestSupportedVersion` here. Be clear about the version we're setting. -- 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