chenxu14 commented on a change in pull request #603: HBASE-22965 RS Crash due 
to DBE reference to an reused ByteBuff
URL: https://github.com/apache/hbase/pull/603#discussion_r329138404
 
 

 ##########
 File path: 
hbase-server/src/test/java/org/apache/hadoop/hbase/io/hfile/TestHFile.java
 ##########
 @@ -760,5 +763,30 @@ public void testGetShortMidpoint() {
         0, expectedArray.length);
   }
 
+  @Test
+  public void testDBEShipped() throws IOException {
+    for (DataBlockEncoding encoding : DataBlockEncoding.values()) {
+      DataBlockEncoder encoder = encoding.getEncoder();
+      if (encoder == null) {
+        continue;
+      }
+      Path f = new Path(ROOT_DIR, testName.getMethodName() + "_" + encoding);
+      HFileContext context = new HFileContextBuilder()
+          .withIncludesTags(false)
+          .withDataBlockEncoding(encoding).build();
+      HFileWriterImpl writer = (HFileWriterImpl) HFile.getWriterFactory(conf, 
cacheConf)
+          .withPath(fs, f).withFileContext(context).create();
+
+      KeyValue kv = new KeyValue(Bytes.toBytes("testkey"), 
Bytes.toBytes("family"),
+        Bytes.toBytes("qual"), Bytes.toBytes("testvalue"));
+      ByteBuffer buffer = ByteBuffer.wrap(kv.getBuffer());
+      ByteBufferKeyValue bbCell = new ByteBufferKeyValue(buffer, 0, 
buffer.remaining());
+      writer.append(bbCell);
+      writer.beforeShipped();
+
+      Cell cell = writer.blockWriter.getEncodingState().getLastCell();
+      assertTrue(cell instanceof KeyValue);
 
 Review comment:
   thanks for the feedback

----------------------------------------------------------------
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]


With regards,
Apache Git Services

Reply via email to