Fix bad test fix from 0bff481
"Limit receive commands"
In 0bff481d45
to accurately use the two
limits it was necessary to move the LimitedInputStream out of the
PacketLineIn and further down to the PackParser. Unfortuantely this
didn't survive review, as a buggy test failed and the "fix" was to
drop this part of the code.
The maxPackSizeLimit should apply to the pack stream, not the pkt-line
framing used to send commands to control the ReceivePack instance. The
commands are controlled using a different limit. The failing test allowed
too many bytes in the pack and was only failing because it was including
the command framing. The correct fix for the test was simply to drop the
limit lower, to more closely match the actual pack size.
Change-Id: I47d3885b9d7d527e153df7ac9c62fc2865ceecf4
This commit is contained in:
parent
ff6e6c2214
commit
07fdc50c07
|
@ -269,7 +269,7 @@ public void testUnpackErrorWithSubsequentExceptionInPostReceiveHook()
|
|||
Transport t;
|
||||
|
||||
// this maxPackSize leads to an unPackError
|
||||
maxPackSize = 400;
|
||||
maxPackSize = 100;
|
||||
// this PostReceiveHook when called after an unsuccesfull unpack will
|
||||
// lead to an IllegalStateException
|
||||
postHook = new PostReceiveHook() {
|
||||
|
|
|
@ -1058,14 +1058,6 @@ protected void init(final InputStream input, final OutputStream output,
|
|||
rawOut = o;
|
||||
}
|
||||
|
||||
if (maxPackSizeLimit >= 0)
|
||||
rawIn = new LimitedInputStream(rawIn, maxPackSizeLimit) {
|
||||
@Override
|
||||
protected void limitExceeded() throws TooLargePackException {
|
||||
throw new TooLargePackException(limit);
|
||||
}
|
||||
};
|
||||
|
||||
pckIn = new PacketLineIn(rawIn);
|
||||
pckOut = new PacketLineOut(rawOut);
|
||||
pckOut.setFlushOnEnd(false);
|
||||
|
@ -1369,7 +1361,7 @@ private void receivePack() throws IOException {
|
|||
if (getRefLogIdent() != null)
|
||||
lockMsg += " from " + getRefLogIdent().toExternalString(); //$NON-NLS-1$
|
||||
|
||||
parser = ins.newPackParser(rawIn);
|
||||
parser = ins.newPackParser(packInputStream());
|
||||
parser.setAllowThin(true);
|
||||
parser.setNeedNewObjectIds(checkReferencedIsReachable);
|
||||
parser.setNeedBaseObjectIds(checkReferencedIsReachable);
|
||||
|
@ -1389,6 +1381,19 @@ private void receivePack() throws IOException {
|
|||
timeoutIn.setTimeout(timeout * 1000);
|
||||
}
|
||||
|
||||
private InputStream packInputStream() {
|
||||
InputStream packIn = rawIn;
|
||||
if (maxPackSizeLimit >= 0) {
|
||||
packIn = new LimitedInputStream(packIn, maxPackSizeLimit) {
|
||||
@Override
|
||||
protected void limitExceeded() throws TooLargePackException {
|
||||
throw new TooLargePackException(limit);
|
||||
}
|
||||
};
|
||||
}
|
||||
return packIn;
|
||||
}
|
||||
|
||||
private boolean needCheckConnectivity() {
|
||||
return isCheckReceivedObjects()
|
||||
|| isCheckReferencedObjectsAreReachable()
|
||||
|
|
Loading…
Reference in New Issue