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

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


The following commit(s) were added to refs/heads/master by this push:
     new 013abf350b HDDS-12230. Improve error message in `ozone sh key put` 
when file not found (#7829)
013abf350b is described below

commit 013abf350b6a7d57c549ce71641fe9d92968fbc4
Author: sreejasahithi <[email protected]>
AuthorDate: Fri Feb 7 21:34:58 2025 +0530

    HDDS-12230. Improve error message in `ozone sh key put` when file not found 
(#7829)
---
 .../main/java/org/apache/hadoop/ozone/shell/keys/PutKeyHandler.java   | 4 ++++
 hadoop-ozone/dist/src/main/smoketest/basic/ozone-shell-lib.robot      | 4 ++--
 2 files changed, 6 insertions(+), 2 deletions(-)

diff --git 
a/hadoop-ozone/cli-shell/src/main/java/org/apache/hadoop/ozone/shell/keys/PutKeyHandler.java
 
b/hadoop-ozone/cli-shell/src/main/java/org/apache/hadoop/ozone/shell/keys/PutKeyHandler.java
index 30543f7907..65d1bbc0ee 100644
--- 
a/hadoop-ozone/cli-shell/src/main/java/org/apache/hadoop/ozone/shell/keys/PutKeyHandler.java
+++ 
b/hadoop-ozone/cli-shell/src/main/java/org/apache/hadoop/ozone/shell/keys/PutKeyHandler.java
@@ -23,6 +23,7 @@
 import java.io.InputStream;
 import java.io.OutputStream;
 import java.io.RandomAccessFile;
+import java.io.FileNotFoundException;
 import java.nio.ByteBuffer;
 import java.nio.channels.FileChannel;
 import java.nio.file.Files;
@@ -81,6 +82,9 @@ protected void execute(OzoneClient client, OzoneAddress 
address)
     String keyName = address.getKeyName();
 
     File dataFile = new File(fileName);
+    if (!dataFile.exists()) {
+      throw new FileNotFoundException("Error: File not found: " + fileName);
+    }
 
     if (isVerbose()) {
       try (InputStream stream = Files.newInputStream(dataFile.toPath())) {
diff --git a/hadoop-ozone/dist/src/main/smoketest/basic/ozone-shell-lib.robot 
b/hadoop-ozone/dist/src/main/smoketest/basic/ozone-shell-lib.robot
index 16d8f6febf..cbbc511595 100644
--- a/hadoop-ozone/dist/src/main/smoketest/basic/ozone-shell-lib.robot
+++ b/hadoop-ozone/dist/src/main/smoketest/basic/ozone-shell-lib.robot
@@ -131,8 +131,8 @@ Test ozone shell errors
     ${result} =     Execute and checkrc    ozone sh bucket create 
${protocol}${server}/${volume}/bucket1                    255
                     Should contain      ${result}       QUOTA_ERROR
                     Execute and checkrc    ozone sh volume delete 
${protocol}${server}/${volume}                            0
-
-
+    ${result} =     Execute and checkrc    ozone sh key put 
${protocol}${server}/${volume}/bucket1/key1 sample.txt          255
+                    Should Match Regexp                    ${result}       
Error: File not found: .*
 
 Test Volume Acls
     [arguments]     ${protocol}         ${server}       ${volume}


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to