mimaison commented on code in PR #14995: URL: https://github.com/apache/kafka/pull/14995#discussion_r1431221328
########## clients/src/main/java/org/apache/kafka/common/config/provider/FileConfigProvider.java: ########## @@ -84,7 +112,17 @@ public ConfigData get(String path, Set<String> keys) { if (path == null || path.isEmpty()) { return new ConfigData(data); } - try (Reader reader = reader(path)) { + + Path filePath = new File(path).toPath(); Review Comment: Can we use `Paths.get()` instead of creating a `File`? ########## clients/src/main/java/org/apache/kafka/common/config/provider/FileConfigProvider.java: ########## @@ -84,7 +112,17 @@ public ConfigData get(String path, Set<String> keys) { if (path == null || path.isEmpty()) { return new ConfigData(data); } - try (Reader reader = reader(path)) { + + Path filePath = new File(path).toPath(); Review Comment: Same if a couple of other places ########## clients/src/main/java/org/apache/kafka/common/config/provider/FileConfigProvider.java: ########## @@ -84,7 +112,17 @@ public ConfigData get(String path, Set<String> keys) { if (path == null || path.isEmpty()) { return new ConfigData(data); } - try (Reader reader = reader(path)) { + + Path filePath = new File(path).toPath(); + if (allowedPaths != null) { + long allowed = allowedPaths.stream().filter(allowedPath -> filePath.startsWith(allowedPath) || filePath.equals(allowedPath)).count(); Review Comment: Do we need the `equals()` check? I think `startsWith()` return` `true` is both paths are equals. ########## clients/src/test/java/org/apache/kafka/common/config/provider/FileConfigProviderTest.java: ########## @@ -29,22 +32,36 @@ import java.util.ServiceLoader; import java.util.stream.StreamSupport; +import static org.apache.kafka.common.config.provider.DirectoryConfigProvider.ALLOWED_PATHS_CONFIG; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertNull; import static org.junit.jupiter.api.Assertions.assertTrue; public class FileConfigProviderTest { private FileConfigProvider configProvider; + private File parent; + private File dir; + private File dirFile; + private File siblingDir; + private File siblingDirFile; @BeforeEach public void setup() { configProvider = new TestFileConfigProvider(); + configProvider.configure(Collections.emptyMap()); + parent = TestUtils.tempDirectory(); + dir = new File(parent, "dir"); Review Comment: Can we use `java.nio.file.Files` instead of `File`? -- 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