LazyPostReceiveHookChain: Catch IllegalStateException on ReceivePack.getPackSize
The solution in change I0643af77d was incomplete. The pack size can
be uninitialized in cases other than ref deletion. Just try to get
the size and handle the exception, rather than attempt to cover all
the possible cases.
This reverts commit 90305b4b2a
.
Bug: Issue 11918
Change-Id: I5b7683664a0ff549cce7c83d5c7a9aa8b351a7cc
This commit is contained in:
@@ -79,9 +79,20 @@ public class LazyPostReceiveHookChain implements PostReceiveHook {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static boolean affectsSize(ReceivePack rp, Collection<ReceiveCommand> commands) {
|
public static boolean affectsSize(ReceivePack rp, Collection<ReceiveCommand> commands) {
|
||||||
if (commands.stream().allMatch(c -> c.getType() == ReceiveCommand.Type.DELETE)) {
|
long packSize;
|
||||||
|
try {
|
||||||
|
packSize = rp.getPackSize();
|
||||||
|
} catch (IllegalStateException e) {
|
||||||
|
// No pack was received, i.e. ref deletion or wind back
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return rp.getPackSize() > 0L;
|
if (packSize > 0L) {
|
||||||
|
for (ReceiveCommand cmd : commands) {
|
||||||
|
if (cmd.getType() != ReceiveCommand.Type.DELETE) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user