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

Yi Liu commented on HDFS-6392:
------------------------------

Thanks Charles for the patch, I found most of code in this patch has overlap 
with HDFS-6391. 

{code}
   public OutputStream getWrappedStream() {
-    return wrappedStream;
+    if (wrappedStream instanceof CryptoOutputStream) {
+      return ((CryptoOutputStream) wrappedStream).getWrappedStream();
+    } else {
+      return wrappedStream;
+    }
   }
{code}

I see some existing code uses {{getWrappedStream}} to get the wrapped output 
stream, then invoke {{#hflush/#hsync}}, for example: in 
{{HdfsDataOutputStream}} {code}((DFSOutputStream) 
getWrappedStream()).hsync(syncFlags);{code}
So we can’t do {code} return ((CryptoOutputStream) 
wrappedStream).getWrappedStream();{code}, otherwise will break 
{{#hflush/#hsync}} functionality; instead maybe return the {{wrappedStream}} 
directly. Furthermore, in {{HdfsDataOutputStream}} it does {{((DFSOutputStream) 
getWrappedStream())}}, we should also consider this.

>  Wire crypto streams for encrypted files in DFSClient
> -----------------------------------------------------
>
>                 Key: HDFS-6392
>                 URL: https://issues.apache.org/jira/browse/HDFS-6392
>             Project: Hadoop HDFS
>          Issue Type: Sub-task
>          Components: namenode, security
>            Reporter: Alejandro Abdelnur
>            Assignee: Charles Lamb
>         Attachments: HDFS-6392.1.patch, HDFS-6392.2.patch
>
>
> When the DFS client gets a key material and IV for a file being 
> opened/created, it should wrap the stream with a crypto stream initialized 
> with the key material and IV.



--
This message was sent by Atlassian JIRA
(v6.2#6252)

Reply via email to