diff --git a/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt b/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt index 0440ff73b2c..d1fd8ba7c9a 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt +++ b/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt @@ -741,6 +741,9 @@ Release 2.4.0 - UNRELEASED HDFS-5449. WebHdfs compatibility broken between 2.2 and 1.x / 23.x (kihwal) + HDFS-5756. hadoopRzOptionsSetByteBufferPool does not accept NULL argument, + contrary to docs. (cmccabe via wang) + BREAKDOWN OF HDFS-2832 SUBTASKS AND RELATED JIRAS HDFS-4985. Add storage type to the protocol and expose it in block report diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/main/native/libhdfs/hdfs.c b/hadoop-hdfs-project/hadoop-hdfs/src/main/native/libhdfs/hdfs.c index bd1ae5d40ba..07088d09c41 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/main/native/libhdfs/hdfs.c +++ b/hadoop-hdfs-project/hadoop-hdfs/src/main/native/libhdfs/hdfs.c @@ -2174,16 +2174,18 @@ int hadoopRzOptionsSetByteBufferPool( return -1; } - // Note: we don't have to call hadoopRzOptionsClearCached in this - // function, since the ByteBufferPool is passed separately from the - // EnumSet of ReadOptions. + if (className) { + // Note: we don't have to call hadoopRzOptionsClearCached in this + // function, since the ByteBufferPool is passed separately from the + // EnumSet of ReadOptions. - jthr = constructNewObjectOfClass(env, &byteBufferPool, className, "()V"); - if (jthr) { - printExceptionAndFree(env, jthr, PRINT_EXC_ALL, - "hadoopRzOptionsSetByteBufferPool(className=%s): ", className); - errno = EINVAL; - return -1; + jthr = constructNewObjectOfClass(env, &byteBufferPool, className, "()V"); + if (jthr) { + printExceptionAndFree(env, jthr, PRINT_EXC_ALL, + "hadoopRzOptionsSetByteBufferPool(className=%s): ", className); + errno = EINVAL; + return -1; + } } if (opts->byteBufferPool) { // Delete any previous ByteBufferPool we had. diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/main/native/libhdfs/test/test_libhdfs_zerocopy.c b/hadoop-hdfs-project/hadoop-hdfs/src/main/native/libhdfs/test/test_libhdfs_zerocopy.c index b22fee12964..ba6ac0904bf 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/main/native/libhdfs/test/test_libhdfs_zerocopy.c +++ b/hadoop-hdfs-project/hadoop-hdfs/src/main/native/libhdfs/test/test_libhdfs_zerocopy.c @@ -140,6 +140,12 @@ static int doTestZeroCopyReads(hdfsFS fs, const char *fileName) EXPECT_NULL(hadoopReadZero(file, opts, TEST_ZEROCOPY_FULL_BLOCK_SIZE)); EXPECT_INT_EQ(EPROTONOSUPPORT, errno); + /* Verify that setting a NULL ByteBufferPool class works. */ + EXPECT_ZERO(hadoopRzOptionsSetByteBufferPool(opts, NULL)); + EXPECT_ZERO(hadoopRzOptionsSetSkipChecksum(opts, 0)); + EXPECT_NULL(hadoopReadZero(file, opts, TEST_ZEROCOPY_FULL_BLOCK_SIZE)); + EXPECT_INT_EQ(EPROTONOSUPPORT, errno); + /* Now set a ByteBufferPool and try again. It should succeed this time. */ EXPECT_ZERO(hadoopRzOptionsSetByteBufferPool(opts, ELASTIC_BYTE_BUFFER_POOL_CLASS));