HDFS-5445. PacketReceiver populates the packetLen field in PacketHeader incorrectly (Jonathan Mace via Colin P. McCabe)

(cherry picked from commit f761bd8fe4)
This commit is contained in:
Colin Patrick Mccabe 2015-01-12 17:11:03 -08:00
parent dde774f2a4
commit a6ebe7a76b
3 changed files with 8 additions and 2 deletions

View File

@ -422,6 +422,9 @@ Release 2.7.0 - UNRELEASED
HDFS-7533. Datanode sometimes does not shutdown on receiving upgrade
shutdown command (Eric Payne via kihwal)
HDFS-5445. PacketReceiver populates the packetLen field in PacketHeader
incorrectly (Jonathan Mace via Colin P. McCabe)
Release 2.6.1 - UNRELEASED
INCOMPATIBLE CHANGES

View File

@ -178,7 +178,7 @@ public class PacketReceiver implements Closeable {
if (curHeader == null) {
curHeader = new PacketHeader();
}
curHeader.setFieldsFromData(dataPlusChecksumLen, headerBuf);
curHeader.setFieldsFromData(payloadLen, headerBuf);
// Compute the sub-slices of the packet
int checksumLen = dataPlusChecksumLen - curHeader.getDataLen();

View File

@ -27,6 +27,8 @@ import org.apache.hadoop.hdfs.AppendTestUtil;
import org.junit.Test;
import org.mockito.Mockito;
import com.google.common.primitives.Ints;
import static org.junit.Assert.*;
public class TestPacketReceiver {
@ -38,7 +40,7 @@ public class TestPacketReceiver {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
DataOutputStream dos = new DataOutputStream(baos);
int packetLen = data.length + sums.length + 4;
int packetLen = data.length + sums.length + Ints.BYTES;
PacketHeader header = new PacketHeader(
packetLen, OFFSET_IN_BLOCK, SEQNO, false, data.length, false);
header.write(dos);
@ -87,6 +89,7 @@ public class TestPacketReceiver {
PacketHeader header = pr.getHeader();
assertEquals(SEQNO, header.getSeqno());
assertEquals(OFFSET_IN_BLOCK, header.getOffsetInBlock());
assertEquals(dataLen + checksumsLen + Ints.BYTES, header.getPacketLen());
// Mirror the packet to an output stream and make sure it matches
// the packet we sent.