wilkinsona commented on a change in pull request #9947: URL: https://github.com/apache/kafka/pull/9947#discussion_r562467278
########## File path: streams/src/main/java/org/apache/kafka/streams/processor/internals/StateDirectory.java ########## @@ -109,16 +109,27 @@ public StateDirectory(final StreamsConfig config, final Time time, final boolean log.warn("Using /tmp directory in the state.dir property can cause failures with writing the checkpoint file" + " due to the fact that this directory can be cleared by the OS"); } - // change the dir permission to "rwxr-x---" to avoid world readable - final Path basePath = Paths.get(baseDir.getPath()); - final Path statePath = Paths.get(stateDir.getPath()); + configurePermissions(Paths.get(baseDir.getPath())); + configurePermissions(Paths.get(stateDir.getPath())); + } + } + + private void configurePermissions(final Path path) { + if (path.getFileSystem().supportedFileAttributeViews().contains("posix")) { final Set<PosixFilePermission> perms = PosixFilePermissions.fromString("rwxr-x---"); try { - Files.setPosixFilePermissions(basePath, perms); - Files.setPosixFilePermissions(statePath, perms); + Files.setPosixFilePermissions(path, perms); } catch (final IOException e) { - log.error("Error changing permissions for the state or base directory {} ", stateDir.getPath(), e); + log.error("Error changing permissions for the directory {} ", path, e); + } + } else { + final File file = path.toFile(); Review comment: We'd have to pass in both the `Path` and the `File` and introduce the risk of them not being the "same". We need the `Path` to check if `PosixFilePermissions` can be set. It's purely stylistic, but I prefer it as currently written. Your call, though. ---------------------------------------------------------------- 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. For queries about this service, please contact Infrastructure at: us...@infra.apache.org