Skip to content

Commit

Permalink
Revert "Remove deprecated
Browse files Browse the repository at this point in the history
LocalDiskRepositoryTestCase#create(boolean,boolean)"

This reverts commit 3682611.

Reason: removing this deprecated method caused a ton of warnings about
closing an already closed Repository when running tests.

Change-Id: I3e9f224c55c167f92dad39caabfab5e43cf54cfb
  • Loading branch information
msohn committed Sep 3, 2024
1 parent b4bdf98 commit 45689b4
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -422,11 +422,32 @@ protected FileRepository createWorkRepository() throws IOException {
*/
protected FileRepository createRepository(boolean bare)
throws IOException {
return createRepository(bare, false /* auto close */);
}

/**
* Creates a new empty repository.
*
* @param bare
* true to create a bare repository; false to make a repository
* within its working directory
* @param autoClose
* auto close the repository in {@link #tearDown()}
* @return the newly created repository, opened for access
* @throws IOException
* the repository could not be created in the temporary area
* @deprecated use {@link #createRepository(boolean)} instead
*/
@Deprecated
public FileRepository createRepository(boolean bare, boolean autoClose)
throws IOException {
File gitdir = createUniqueTestGitDir(bare);
FileRepository db = new FileRepository(gitdir);
assertFalse(gitdir.exists());
db.create(bare);
addRepoToClose(db);
if (autoClose) {
addRepoToClose(db);
}
return db;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -159,8 +159,8 @@ public void testRepositoryUsageCount() throws Exception {
@Test
public void testRepositoryUsageCountWithRegisteredRepository()
throws IOException {
@SuppressWarnings("resource") // We are testing the close() method
Repository repo = createRepository(false);
@SuppressWarnings({"resource", "deprecation"}) // We are testing the close() method
Repository repo = createRepository(false, false);
assertEquals(1, repo.useCnt.get());
RepositoryCache.register(repo);
assertEquals(1, repo.useCnt.get());
Expand Down Expand Up @@ -207,8 +207,10 @@ public void testRepositoryUnregisteringWhenExpiredAndUsageCountNegative()

@Test
public void testRepositoryUnregisteringWhenExpired() throws Exception {
Repository repoA = createRepository(true);
Repository repoB = createRepository(true);
@SuppressWarnings({"resource", "deprecation"}) // We are testing the close() method
Repository repoA = createRepository(true, false);
@SuppressWarnings({"resource", "deprecation"}) // We are testing the close() method
Repository repoB = createRepository(true, false);
Repository repoC = createBareRepository();
RepositoryCache.register(repoA);
RepositoryCache.register(repoB);
Expand Down Expand Up @@ -241,7 +243,8 @@ public void testRepositoryUnregisteringWhenExpired() throws Exception {

@Test
public void testReconfigure() throws InterruptedException, IOException {
Repository repo = createRepository(false);
@SuppressWarnings({"resource", "deprecation"}) // We are testing the close() method
Repository repo = createRepository(false, false);
RepositoryCache.register(repo);
assertTrue(RepositoryCache.isCached(repo));
repo.close();
Expand Down

0 comments on commit 45689b4

Please sign in to comment.