diff --git a/standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/utils/FileUtils.java b/standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/utils/FileUtils.java index cf8825ec1612..5816c79f7d35 100644 --- a/standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/utils/FileUtils.java +++ b/standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/utils/FileUtils.java @@ -17,7 +17,6 @@ */ package org.apache.hadoop.hive.metastore.utils; -import java.io.FileNotFoundException; import java.io.IOException; import java.net.URI; import java.util.ArrayList; @@ -85,6 +84,10 @@ public static boolean moveToTrash(FileSystem fs, Path f, Configuration conf, boo LOG.debug("deleting " + f); boolean result; try { + if (!fs.exists(f)) { + LOG.info("The path to moveToTrash does not exist: " + f); + return true; + } if(purge) { LOG.debug("purge is set to true. Not moving to Trash " + f); } else { diff --git a/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/HiveMetaStoreFsImpl.java b/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/HiveMetaStoreFsImpl.java index e129d4515742..9721668be184 100644 --- a/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/HiveMetaStoreFsImpl.java +++ b/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/HiveMetaStoreFsImpl.java @@ -18,8 +18,6 @@ package org.apache.hadoop.hive.metastore; -import java.io.FileNotFoundException; - import org.apache.hadoop.hive.metastore.utils.FileUtils; import org.apache.hadoop.hive.metastore.utils.MetaStoreUtils; import org.slf4j.Logger; @@ -41,15 +39,9 @@ public boolean deleteDir(FileSystem fs, Path f, boolean recursive, if (FileUtils.moveToTrash(fs, f, conf, ifPurge)) { return true; } - if (fs.exists(f)) { - throw new MetaException("Unable to delete directory: " + f); - } - return true; - } catch (FileNotFoundException e) { - return true; // ok even if there is not data } catch (Exception e) { MetaStoreUtils.throwMetaException(e); } - return false; + throw new MetaException("Unable to delete directory: " + f); } }