Index: hbase-server/src/main/java/org/apache/hadoop/hbase/io/hfile/HFileBlock.java =================================================================== --- hbase-server/src/main/java/org/apache/hadoop/hbase/io/hfile/HFileBlock.java (revision 1407344) +++ hbase-server/src/main/java/org/apache/hadoop/hbase/io/hfile/HFileBlock.java (working copy) @@ -129,8 +129,8 @@ public static final int BYTE_BUFFER_HEAP_SIZE = (int) ClassSize.estimateBase( ByteBuffer.wrap(new byte[0], 0, 0).getClass(), false); - static final int EXTRA_SERIALIZATION_SPACE = Bytes.SIZEOF_LONG + - Bytes.SIZEOF_INT; + static final int EXTRA_SERIALIZATION_SPACE = Bytes.SIZEOF_INT + + Bytes.SIZEOF_LONG + Bytes.SIZEOF_INT; /** * Each checksum value is an integer that can be stored in 4 bytes. @@ -145,11 +145,10 @@ buf.limit(buf.limit() - HFileBlock.EXTRA_SERIALIZATION_SPACE).rewind(); newByteBuffer.put(buf); - HFileBlock ourBuffer = new HFileBlock(newByteBuffer, - MINOR_VERSION_NO_CHECKSUM); - buf.position(buf.limit()); buf.limit(buf.limit() + HFileBlock.EXTRA_SERIALIZATION_SPACE); + int minorVersion=buf.getInt(); + HFileBlock ourBuffer = new HFileBlock(newByteBuffer, minorVersion); ourBuffer.offset = buf.getLong(); ourBuffer.nextBlockOnDiskSizeWithHeader = buf.getInt(); return ourBuffer; @@ -1798,7 +1797,10 @@ @Override public void serialize(ByteBuffer destination) { - destination.put(this.buf.duplicate()); + ByteBuffer dupBuf = this.buf.duplicate(); + dupBuf.rewind(); + destination.put(dupBuf); + destination.putInt(this.minorVersion); destination.putLong(this.offset); destination.putInt(this.nextBlockOnDiskSizeWithHeader); destination.rewind();