]> source.dussan.org Git - jgit.git/commitdiff
UploadPackTest: fix unclosed resource warning 15/1203915/1
authorMatthias Sohn <matthias.sohn@sap.com>
Tue, 19 Nov 2024 12:17:08 +0000 (13:17 +0100)
committerMatthias Sohn <matthias.sohn@sap.com>
Tue, 19 Nov 2024 12:17:08 +0000 (13:17 +0100)
Change-Id: I4efccd72bd567d42e739ee330e26c6b04d5c5c01

org.eclipse.jgit.test/tst/org/eclipse/jgit/transport/UploadPackTest.java

index 017104c527875400adb4ce4540fcb2b654b3d441..064d863bf69afc418a1608019c2a5dba5e95f18f 100644 (file)
@@ -2862,7 +2862,7 @@ public class UploadPackTest {
                RevTag heavyTag2 = remote.tag("middleTagRing", heavyTag1);
                remote.lightweightTag("refTagRing", heavyTag2);
 
-               UploadPack uploadPack = new UploadPack(remote.getRepository());
+               try (UploadPack uploadPack = new UploadPack(remote.getRepository())) {
 
                ByteArrayOutputStream cli = new ByteArrayOutputStream();
                PacketLineOut clientWant = new PacketLineOut(cli);
@@ -2872,7 +2872,6 @@ public class UploadPackTest {
                clientWant.writeString("done\n");
 
                try (ByteArrayOutputStream serverResponse = new ByteArrayOutputStream()) {
-
                        uploadPack.setPreUploadHook(new PreUploadHook() {
                                @Override
                                public void onBeginNegotiateRound(UploadPack up,
@@ -2925,6 +2924,7 @@ public class UploadPackTest {
                        assertTrue(objDb.has(heavyTag2.toObjectId()));
                }
        }
+}
 
        @Test
        public void testSingleBranchShallowCloneTagChainWithReflessTag() throws Exception {
@@ -2936,7 +2936,7 @@ public class UploadPackTest {
                RevTag tag3 = remote.tag("t3", tag2);
                remote.lightweightTag("t3", tag3);
 
-               UploadPack uploadPack = new UploadPack(remote.getRepository());
+               try (UploadPack uploadPack = new UploadPack(remote.getRepository())) {
 
                ByteArrayOutputStream cli = new ByteArrayOutputStream();
                PacketLineOut clientWant = new PacketLineOut(cli);
@@ -2946,7 +2946,6 @@ public class UploadPackTest {
                clientWant.writeString("done\n");
 
                try (ByteArrayOutputStream serverResponse = new ByteArrayOutputStream()) {
-
                        uploadPack.setPreUploadHook(new PreUploadHook() {
                                @Override
                                public void onBeginNegotiateRound(UploadPack up,
@@ -2994,6 +2993,7 @@ public class UploadPackTest {
                        assertTrue(objDb.has(one.toObjectId()));
                }
        }
+}
 
        @Test
        public void testSafeToClearRefsInFetchV0() throws Exception {