hadoop-common-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Alejandro Abdelnur (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (HADOOP-10662) NullPointerException in CryptoInputStream while wrapped stream is not ByteBufferReadable. Add tests using normal stream.
Date Wed, 04 Jun 2014 15:33:03 GMT

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

Alejandro Abdelnur commented on HADOOP-10662:
---------------------------------------------

Yi, the current logic, while correct seems a bit too complex. Under what circumstances you
would have an {{InputStream}} that implements {{ByteBufferReadable}} but does not support
the {{read(ByteBuffer)}} operation? It seems to me that would be an incorrect implementation
of such interface, no?
------
      if (usingByteBufferRead == null) {
        if (in instanceof ByteBufferReadable) {
          try {
            n = ((ByteBufferReadable) in).read(inBuffer);
            usingByteBufferRead = Boolean.TRUE;
          } catch (UnsupportedOperationException e) {
            usingByteBufferRead = Boolean.FALSE;
          }
        } else {
          usingByteBufferRead = Boolean.FALSE;
        }
        if (!usingByteBufferRead) {
          n = readFromUnderlyingStream(inBuffer);
        }
      } else {
        if (usingByteBufferRead) {
          n = ((ByteBufferReadable) in).read(inBuffer);
        } else {
          n = readFromUnderlyingStream(inBuffer);
        }
      }
------

If we assume that any {{InputStream}} implementing {{ByteBufferReadable}} supports the {{read(ByteBuffer)}}
then the above code could be simplified to:

------
      if (usingByteBufferRead == null) {
        usingByteBufferRead = (in instanceof ByteBufferReadable);
      }
      if (usingByteBufferRead) {
        n = ((ByteBufferReadable) in).read(inBuffer);
      } else {
        n = readFromUnderlyingStream(inBuffer);
      }
------

Or am I missing something obvious?




> NullPointerException in CryptoInputStream while wrapped stream is not ByteBufferReadable.
Add tests using normal stream.
> ------------------------------------------------------------------------------------------------------------------------
>
>                 Key: HADOOP-10662
>                 URL: https://issues.apache.org/jira/browse/HADOOP-10662
>             Project: Hadoop Common
>          Issue Type: Sub-task
>          Components: security
>    Affects Versions: fs-encryption (HADOOP-10150 and HDFS-6134)
>            Reporter: Yi Liu
>            Assignee: Yi Liu
>             Fix For: fs-encryption (HADOOP-10150 and HDFS-6134)
>
>         Attachments: HADOOP-10662.patch
>
>
> NullPointerException in CryptoInputStream while wrapped stream is not ByteBufferReadable.

> Add tests for crypto streams using normal stream which does not support the additional
interfaces that the Hadoop FileSystem streams implement (Seekable, PositionedReadable, ByteBufferReadable,
HasFileDescriptor, CanSetDropBehind, CanSetReadahead, HasEnhancedByteBufferAccess, Syncable,
CanSetDropBehind).



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

Mime
View raw message