hudi-agent commented on code in PR #19904:
URL: https://github.com/apache/hudi/pull/19904#discussion_r3986597934


##########
hudi-hadoop-common/src/test/java/org/apache/hudi/common/util/TestFileIOUtils.java:
##########
@@ -98,6 +101,61 @@ public void testGetConfiguredLocalDirs() {
             envMaps.get("LOCAL_DIRS"));
   }
 
+  @Test
+  public void testGetConfiguredLocalDirsPrefersSparkLocalDirs() {
+    Map<String, String> envMaps = mutableEnv();
+    String originalContainerId = envMaps.get("CONTAINER_ID");
+    String originalLocalDirs = envMaps.get("LOCAL_DIRS");
+    String originalSparkLocalDirs = envMaps.get("SPARK_LOCAL_DIRS");
+    try {
+      // Not under YARN: SPARK_LOCAL_DIRS is used in preference to 
java.io.tmpdir.
+      envMaps.remove("CONTAINER_ID");
+      envMaps.remove("LOCAL_DIRS");
+      envMaps.put("SPARK_LOCAL_DIRS", "/spark-dir-1");
+      assertEquals("/spark-dir-1", String.join("", 
FileIOUtils.getConfiguredLocalDirs()));
+
+      // Comma separated values are split, as they are for YARN.
+      envMaps.put("SPARK_LOCAL_DIRS", "/spark-dir-1,/spark-dir-2");
+      assertEquals(Arrays.asList("/spark-dir-1", "/spark-dir-2"),
+          Arrays.asList(FileIOUtils.getConfiguredLocalDirs()));
+
+      // YARN keeps precedence when both are present.
+      envMaps.put("CONTAINER_ID", "container_xxx");
+      envMaps.put("LOCAL_DIRS", "/yarn-dir");
+      assertEquals("/yarn-dir", String.join("", 
FileIOUtils.getConfiguredLocalDirs()));
+
+      // Neither set: unchanged fallback to java.io.tmpdir.
+      envMaps.remove("CONTAINER_ID");

Review Comment:
   🤖 nit: this reflection-based env access duplicates the inline logic already 
used at the top of `testGetConfiguredLocalDirs` (field "m" lookup). Worth 
factoring both into a single shared private helper to avoid two copies of the 
same reflection hack.
   
   <sub><i>⚠️ AI-generated; verify before applying. React 👍/👎 to flag 
quality.</i></sub>



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to