[ 
https://issues.apache.org/jira/browse/HIVE-7929?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14118766#comment-14118766
 ] 

Josh Elser commented on HIVE-7929:
----------------------------------

The catch block is unnecessary. I think the finally block should only contain 
{{zos.close()}} with {{zos.closeEntry();}} and {{zipDir(dir, relativePath, zos, 
true);}} moved inside of the try block. For example:

{code}
try {
 ...
  zos.closeEntry();
  zipDir(dir, relativePath, zos, true);
} finally {
  zos.close();
}
{code}

Alternatively, it might be cleaner to do a try/finally in {{createJar(File, 
File)}} to close the JarOutputStream and completely remove the {{close()}} call 
in {{jarDir(File, String, ZipOutputStream)}}.

Also, it may interest you, this code was borrowed from HBase. They may benefit 
from these same improvements in their codebase -- I forget what HBase version I 
copied this from though.

> close of ZipOutputStream in Utils#jarDir() should be placed in finally block
> ----------------------------------------------------------------------------
>
>                 Key: HIVE-7929
>                 URL: https://issues.apache.org/jira/browse/HIVE-7929
>             Project: Hive
>          Issue Type: Bug
>    Affects Versions: 0.13.1
>            Reporter: skrho
>            Assignee: skrho
>            Priority: Minor
>              Labels: patch
>         Attachments: HIVE-7929_001.patch
>
>
> In accumulo-handler/src/java/org/apache/hadoop/hive/accumulo/Utils.java , 
> line 308 :
> zos.closeEntry();
> zipDir(dir, relativePath, zos, true);
> zos.close();
> If exception is happened, ZipOutputStream would be left unclosed..



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to