This is an automated email from the ASF dual-hosted git repository.

zhangbutao pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/hive.git


The following commit(s) were added to refs/heads/master by this push:
     new eb79f4086e2 HIVE-28081: Code refine on 
ClearDanglingScratchDir::removeLocalTmpFiles (#5090)(Butao Zhang, reviewed by 
okumin, Stamatis Zampetakis)
eb79f4086e2 is described below

commit eb79f4086e2a2f6a332605368a568462ae742070
Author: Butao Zhang <zhangbu...@cmss.chinamobile.com>
AuthorDate: Wed Feb 21 20:50:20 2024 +0800

    HIVE-28081: Code refine on ClearDanglingScratchDir::removeLocalTmpFiles 
(#5090)(Butao Zhang, reviewed by okumin, Stamatis Zampetakis)
---
 .../apache/hadoop/hive/ql/session/ClearDanglingScratchDir.java   | 9 ++-------
 1 file changed, 2 insertions(+), 7 deletions(-)

diff --git 
a/ql/src/java/org/apache/hadoop/hive/ql/session/ClearDanglingScratchDir.java 
b/ql/src/java/org/apache/hadoop/hive/ql/session/ClearDanglingScratchDir.java
index 576a38d1960..30592302380 100644
--- a/ql/src/java/org/apache/hadoop/hive/ql/session/ClearDanglingScratchDir.java
+++ b/ql/src/java/org/apache/hadoop/hive/ql/session/ClearDanglingScratchDir.java
@@ -252,17 +252,12 @@ public class ClearDanglingScratchDir implements Runnable {
    */
   private void removeLocalTmpFiles(String sessionName, String localTmpdir) {
     File[] files = new File(localTmpdir).listFiles(fn -> 
fn.getName().startsWith(sessionName));
-    boolean success;
     if (files != null) {
       for (File file : files) {
-        success = false;
-        if (file.canWrite()) {
-          success = file.delete();
-        }
-        if (success) {
+        if (file.canWrite() && file.delete()) {
           consoleMessage("While removing '" + sessionName + "' dangling 
scratch dir from HDFS, "
                   + "local tmp session file '" + file.getPath() + "' has been 
cleaned as well.");
-        } else if (file.getName().startsWith(sessionName)) {
+        } else {
           consoleMessage("Even though '" + sessionName + "' is marked as 
dangling session dir, "
                   + "local tmp session file '" + file.getPath() + "' could not 
be removed.");
         }

Reply via email to