ソースを参照

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
tags/v4.7.0.201704051617-r
Shawn Pearce 7年前
コミット
07fdc50c07

+ 1
- 1
org.eclipse.jgit.http.test/tst/org/eclipse/jgit/http/test/GitServletResponseTests.java ファイルの表示

@@ -269,7 +269,7 @@ public class GitServletResponseTests extends HttpTestCase {
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() {

+ 14
- 9
org.eclipse.jgit/src/org/eclipse/jgit/transport/BaseReceivePack.java ファイルの表示

@@ -1058,14 +1058,6 @@ public abstract class BaseReceivePack {
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 @@ public abstract class BaseReceivePack {
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 @@ public abstract class BaseReceivePack {
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()

読み込み中…
キャンセル
保存