]> source.dussan.org Git - jgit.git/commitdiff
UploadPackTest#testUploadRedundantBytes: ensure test repo is closed 87/170187/1
authorMatthias Sohn <matthias.sohn@sap.com>
Thu, 1 Oct 2020 23:17:37 +0000 (01:17 +0200)
committerMatthias Sohn <matthias.sohn@sap.com>
Thu, 1 Oct 2020 23:18:18 +0000 (01:18 +0200)
This fixes a resource leak warning.

Change-Id: I65166eeefc719ea577963c84ce2059e2d7e6c1d7
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
org.eclipse.jgit.test/tst/org/eclipse/jgit/transport/UploadPackTest.java

index 55caa64d87a22d300ed32dc692939055710a6be6..ce546e357e121c25f8906d8b39b59028bc6dcf90 100644 (file)
@@ -1117,13 +1117,16 @@ public class UploadPackTest {
                RevCommit child = remote.commit(remote.tree(remote.file("foo", childBlob)), parent);
                remote.update("branch1", child);
 
-               TestRepository<InMemoryRepository> local = new TestRepository<>(client);
-               RevBlob localParentBlob = local.blob(commonInBlob + "a");
-               RevCommit localParent = local.commit(local.tree(local.file("foo", localParentBlob)));
-               RevBlob localChildBlob = local.blob(commonInBlob + "b");
-               RevCommit localChild = local.commit(
-                               local.tree(local.file("foo", localChildBlob)), localParent);
-               local.update("branch1", localChild);
+               try (TestRepository<InMemoryRepository> local = new TestRepository<>(
+                               client)) {
+                       RevBlob localParentBlob = local.blob(commonInBlob + "a");
+                       RevCommit localParent = local
+                                       .commit(local.tree(local.file("foo", localParentBlob)));
+                       RevBlob localChildBlob = local.blob(commonInBlob + "b");
+                       RevCommit localChild = local.commit(
+                                       local.tree(local.file("foo", localChildBlob)), localParent);
+                       local.update("branch1", localChild);
+               }
 
                ByteArrayInputStream recvStream = uploadPackV2(
                                "command=fetch\n",