[ 
https://issues.apache.org/jira/browse/HDDS-2580?focusedWorklogId=346702&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-346702
 ]

ASF GitHub Bot logged work on HDDS-2580:
----------------------------------------

                Author: ASF GitHub Bot
            Created on: 20/Nov/19 13:22
            Start Date: 20/Nov/19 13:22
    Worklog Time Spent: 10m 
      Work Description: adoroszlai commented on pull request #235: HDDS-2580. 
Ensure resources are closed in Get/PutKeyHandler
URL: https://github.com/apache/hadoop-ozone/pull/235
 
 
   ## What changes were proposed in this pull request?
   
   1. Ensure input/output streams are closed in `GetKeyHandler` and 
`PutKeyHandler`
   2. Remove unreachable `else` branch (`dataFilePath` is never `null`)
   3. Use more generic types (`InputStream`/`OutputStream`)
   4. Replace `Boolean.valueOf` with `Boolean.parseBoolean` (avoid unnecessary 
boxing)
   5. Fix typo in overwrite error message (`will` -> `would`)
   
   https://issues.apache.org/jira/browse/HDDS-2580
   
   ## How was this patch tested?
   
   Tested both `key put` and `key get` on compose-based cluster:
   
   ```
   $ ozone freon ockg -t 1 -n 1 -p key
   ...
   
   $ ozone sh key put vol1/bucket1/key/test /etc/passwd
   $ ozone sh key get vol1/bucket1/key/test test.txt
   $ diff -q test.txt /etc/passwd
   
   $ ozone sh --verbose key put vol1/bucket1/key/verbose /etc/group
   Volume Name : vol1
   Bucket Name : bucket1
   Key Name : key/verbose
   File Hash : dce24e3a2699f6acc55bc913bd92ce61
   $ ozone sh --verbose key get vol1/bucket1/key/verbose verbose.txt
   Volume Name : vol1
   Bucket Name : bucket1
   Key Name : key/verbose
   Downloaded file hash : dce24e3a2699f6acc55bc913bd92ce61
   $ diff -q verbose.txt /etc/group
   
   $ ozone sh key get vol1/bucket1/key/test /etc/passwd
   /etc/passwd exists. Download would overwrite an existing file. Aborting.
   
   $ ozone sh key get vol1/bucket1/key/test /a/b/c/d
   /a/b/c/d (No such file or directory)
   
   $ ozone sh --verbose key get vol1/bucket1/key/test /a/b/c/d
   Volume Name : vol1
   Bucket Name : bucket1
   Key Name : key/test
   java.io.FileNotFoundException: /a/b/c/d (No such file or directory)
   ...
   
   $ ozone sh key put vol1/bucket1/key/error1 /a/b/c
   /a/b/c (No such file or directory)
   
   $ ozone sh --verbose key put vol1/bucket1/key/error2 /a/b/c
   Volume Name : vol1
   Bucket Name : bucket1
   Key Name : key/error2
   java.io.FileNotFoundException: /a/b/c (No such file or directory)
   ...
   ```
 
----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
[email protected]


Issue Time Tracking
-------------------

            Worklog Id:     (was: 346702)
    Remaining Estimate: 0h
            Time Spent: 10m

> Ensure resources are closed in Get/PutKeyHandler
> ------------------------------------------------
>
>                 Key: HDDS-2580
>                 URL: https://issues.apache.org/jira/browse/HDDS-2580
>             Project: Hadoop Distributed Data Store
>          Issue Type: Bug
>            Reporter: Dinesh Chitlangia
>            Assignee: Attila Doroszlai
>            Priority: Major
>              Labels: newbie, pull-request-available, sonar
>          Time Spent: 10m
>  Remaining Estimate: 0h
>
> Use try-with-resources or close this "FileOutputStream" in a "finally" clause.
> GetKeyHandler: 
> [https://sonarcloud.io/project/issues?id=hadoop-ozone&issues=AW6HHKTfdBVcJdcVFsvC&open=AW6HHKTfdBVcJdcVFsvC]
>  
> Use try-with-resources or close this "OzoneOutputStream" in a "finally" 
> clause.
> PutKeyHandler: 
> [https://sonarcloud.io/project/issues?id=hadoop-ozone&issues=AW6HHKRodBVcJdcVFsvB&open=AW6HHKRodBVcJdcVFsvB]
>  



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

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

Reply via email to