wombatu-kun commented on code in PR #19904:
URL: https://github.com/apache/hudi/pull/19904#discussion_r4100986850


##########
hudi-hadoop-common/src/test/java/org/apache/hudi/common/util/TestFileIOUtils.java:
##########
@@ -80,24 +107,60 @@ public void testReadAsUTFStringLines() {
   
   @Test
   public void testGetConfiguredLocalDirs() {
-    Map<String, String> env = System.getenv();
-    Class<?> clazz = env.getClass();
-    Map<String, String> envMaps = null;
-    try {
-      Field field = clazz.getDeclaredField("m");
-      field.setAccessible(true);
-      envMaps = (Map<String, String>) field.get(env);
-      envMaps.put("CONTAINER_ID", "xxxxx");
-    } catch (NoSuchFieldException | IllegalAccessException e) {
-      throw new IllegalArgumentException(e);
-    }
+    Map<String, String> envMaps = mutableEnv();
     assertEquals(String.join("", FileIOUtils.getConfiguredLocalDirs()),
             System.getProperty("java.io.tmpdir"));
+    envMaps.put("CONTAINER_ID", "xxxxx");

Review Comment:
   Moving `CONTAINER_ID` below the first assertion drops the only check that 
`CONTAINER_ID` without `LOCAL_DIRS` is not treated as YARN, so deleting the 
`LOCAL_DIRS` half of `isRunningInYarnContainer` would no longer fail any test. 
Putting this `put` back above the first `assertEquals` restores that check, and 
the new `@AfterEach` keeps it from leaking into later tests.



-- 
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