Expose public getDepth method

The clone or fetch depth is a valuable bit of information
for access logging. Create a public getter to faciliate access.
A precondition check prevents unintentional misuse when the
data isn't valid yet.

Change-Id: I4603d5fd3bd4a767e3e2419b0f2da3664cfbd7f8
Signed-off-by: David Pletcher <dpletcher@google.com>
This commit is contained in:
David Pletcher 2015-04-16 12:47:15 -07:00
parent 41c4f9cb2a
commit 12e38d7275
1 changed files with 13 additions and 0 deletions

View File

@ -884,6 +884,19 @@ private void recvWants() throws IOException {
}
}
/**
* Returns the clone/fetch depth. Valid only after calling recvWants().
*
* @return the depth requested by the client, or 0 if unbounded.
* @since 4.0
*/
public int getDepth() {
if (options == null) {
throw new IllegalStateException("do not call getDepth() before recvWants()");
}
return depth;
}
private boolean negotiate() throws IOException {
okToGiveUp = Boolean.FALSE;