diff --git a/org.eclipse.jgit.http.test/tst/org/eclipse/jgit/http/test/HookMessageTest.java b/org.eclipse.jgit.http.test/tst/org/eclipse/jgit/http/test/HookMessageTest.java index adb69ec27..7795658ea 100644 --- a/org.eclipse.jgit.http.test/tst/org/eclipse/jgit/http/test/HookMessageTest.java +++ b/org.eclipse.jgit.http.test/tst/org/eclipse/jgit/http/test/HookMessageTest.java @@ -149,11 +149,9 @@ public void testPush_CreateBranch() throws Exception { final RevCommit Q = src.commit().add("Q", Q_txt).create(); final Repository db = src.getRepository(); final String dstName = Constants.R_HEADS + "new.branch"; - Transport t; PushResult result; - t = Transport.open(db, remoteURI); - try { + try (Transport t = Transport.open(db, remoteURI)) { final String srcExpr = Q.name(); final boolean forceUpdate = false; final String localName = null; @@ -163,8 +161,6 @@ public void testPush_CreateBranch() throws Exception { srcExpr, dstName, forceUpdate, localName, oldId); result = t.push(NullProgressMonitor.INSTANCE, Collections .singleton(update)); - } finally { - t.close(); } assertTrue(remoteRepository.hasObject(Q_txt)); @@ -193,12 +189,10 @@ public void testPush_HookMessagesToOutputStream() throws Exception { final RevCommit Q = src.commit().add("Q", Q_txt).create(); final Repository db = src.getRepository(); final String dstName = Constants.R_HEADS + "new.branch"; - Transport t; PushResult result; - t = Transport.open(db, remoteURI); OutputStream out = new ByteArrayOutputStream(); - try { + try (Transport t = Transport.open(db, remoteURI)) { final String srcExpr = Q.name(); final boolean forceUpdate = false; final String localName = null; @@ -208,8 +202,6 @@ public void testPush_HookMessagesToOutputStream() throws Exception { srcExpr, dstName, forceUpdate, localName, oldId); result = t.push(NullProgressMonitor.INSTANCE, Collections.singleton(update), out); - } finally { - t.close(); } String expectedMessage = "message line 1\n" //