Merge branch 'stable-3.0' into stable-3.1
* stable-3.0:
RepositorySizeQuotaIT: change try/catch to assertThrows
Enforce repository size on pack rather than on object
Change-Id: I0936e512047c8c0a947a4470fd204b0ea4d32a27
diff --git a/java/com/google/gerrit/acceptance/InProcessProtocol.java b/java/com/google/gerrit/acceptance/InProcessProtocol.java
index feda6bf..75e5a2e 100644
--- a/java/com/google/gerrit/acceptance/InProcessProtocol.java
+++ b/java/com/google/gerrit/acceptance/InProcessProtocol.java
@@ -343,7 +343,7 @@
.project(req.project)
.availableTokens(REPOSITORY_SIZE_GROUP);
availableTokens.throwOnError();
- availableTokens.availableTokens().ifPresent(v -> rp.setMaxObjectSizeLimit(v));
+ availableTokens.availableTokens().ifPresent(rp::setMaxPackSizeLimit);
ImmutableList<PostReceiveHook> hooks =
ImmutableList.<PostReceiveHook>builder()
diff --git a/java/com/google/gerrit/server/git/receive/AsyncReceiveCommits.java b/java/com/google/gerrit/server/git/receive/AsyncReceiveCommits.java
index 68d2010..f5c3aa9 100644
--- a/java/com/google/gerrit/server/git/receive/AsyncReceiveCommits.java
+++ b/java/com/google/gerrit/server/git/receive/AsyncReceiveCommits.java
@@ -331,7 +331,7 @@
REPOSITORY_SIZE_GROUP, projectName);
throw new RuntimeException(e);
}
- availableTokens.availableTokens().ifPresent(v -> receivePack.setMaxObjectSizeLimit(v));
+ availableTokens.availableTokens().ifPresent(receivePack::setMaxPackSizeLimit);
}
/** Determine if the user can upload commits. */
diff --git a/javatests/com/google/gerrit/acceptance/server/quota/RepositorySizeQuotaIT.java b/javatests/com/google/gerrit/acceptance/server/quota/RepositorySizeQuotaIT.java
index 801288a..2692584 100644
--- a/javatests/com/google/gerrit/acceptance/server/quota/RepositorySizeQuotaIT.java
+++ b/javatests/com/google/gerrit/acceptance/server/quota/RepositorySizeQuotaIT.java
@@ -34,7 +34,7 @@
import com.google.gerrit.server.quota.QuotaResponse;
import com.google.inject.Module;
import java.util.Collections;
-import org.eclipse.jgit.api.errors.TooLargeObjectInPackException;
+import org.eclipse.jgit.api.errors.TooLargePackException;
import org.eclipse.jgit.api.errors.TransportException;
import org.junit.Before;
import org.junit.Test;
@@ -77,7 +77,7 @@
@Test
public void pushWithAvailableTokens() throws Exception {
when(quotaBackendWithResource.availableTokens(REPOSITORY_SIZE_GROUP))
- .thenReturn(singletonAggregation(ok(276L)));
+ .thenReturn(singletonAggregation(ok(277L)));
when(quotaBackendWithResource.requestTokens(eq(REPOSITORY_SIZE_GROUP), anyLong()))
.thenReturn(singletonAggregation(ok()));
when(quotaBackendWithUser.project(project)).thenReturn(quotaBackendWithResource);
@@ -91,12 +91,10 @@
when(quotaBackendWithResource.availableTokens(REPOSITORY_SIZE_GROUP))
.thenReturn(singletonAggregation(ok(availableTokens)));
when(quotaBackendWithUser.project(project)).thenReturn(quotaBackendWithResource);
- TooLargeObjectInPackException thrown =
- assertThrows(TooLargeObjectInPackException.class, () -> pushCommit());
- assertThat(thrown).hasMessageThat().contains("Object too large");
- assertThat(thrown)
- .hasMessageThat()
- .contains(String.format("Max object size limit is %d bytes.", availableTokens));
+ assertThat(assertThrows(TooLargePackException.class, () -> pushCommit()).getMessage())
+ .contains(
+ String.format(
+ "Pack exceeds the limit of %d bytes, rejecting the pack", availableTokens));
}
@Test