HDFS-5445. PacketReceiver populates the packetLen field in PacketHeader incorrectly (Jonathan Mace via Colin P. McCabe)
This commit is contained in:
parent
b3ddd7ee39
commit
f761bd8fe4
@ -679,6 +679,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
|
||||
|
@ -178,7 +178,7 @@ private void doRead(ReadableByteChannel ch, InputStream in)
|
||||
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();
|
||||
|
@ -27,6 +27,8 @@
|
||||
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 @@ private byte[] prepareFakePacket(byte[] data, byte[] sums) throws IOException {
|
||||
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 @@ private void doTestReceiveAndMirror(PacketReceiver pr,
|
||||
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.
|
||||
|
Loading…
Reference in New Issue
Block a user