Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCarsten Hammer2019-05-12 10:24:41 -0400
committerMichael Keppler2019-05-15 02:00:12 -0400
commit6997c809ef8f6e89dac065d693185286d0af83f6 (patch)
tree7a8a3bbf997d7f38c59b729a9b4b23225695d585 /org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/test
parentf7252caf1b30cd08badd7480a8130f0e55daf723 (diff)
downloadegit-6997c809ef8f6e89dac065d693185286d0af83f6.tar.gz
egit-6997c809ef8f6e89dac065d693185286d0af83f6.tar.xz
egit-6997c809ef8f6e89dac065d693185286d0af83f6.zip
Use try-with-resources
Convert try finally block to try-with-resources Change-Id: I29a482e2bbfe5e9029b41c1fe7a5bf45308905c2 Signed-off-by: Carsten Hammer <carsten.hammer@t-online.de>
Diffstat (limited to 'org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/test')
-rw-r--r--org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/test/TestUtil.java9
-rw-r--r--org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/test/team/actions/BranchAndResetActionTest.java5
-rw-r--r--org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/test/team/actions/CompareActionsTest.java12
3 files changed, 9 insertions, 17 deletions
diff --git a/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/test/TestUtil.java b/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/test/TestUtil.java
index 17e62768b..a586299bc 100644
--- a/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/test/TestUtil.java
+++ b/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/test/TestUtil.java
@@ -292,14 +292,9 @@ public class TestUtil {
*/
public static void appendFileContent(File file, String content, boolean append)
throws IOException {
- Writer fw = null;
- try {
- fw = new OutputStreamWriter(new FileOutputStream(file, append),
- "UTF-8");
+ try (Writer fw = new OutputStreamWriter(new FileOutputStream(file, append),
+ "UTF-8")) {
fw.append(content);
- } finally {
- if (fw != null)
- fw.close();
}
}
diff --git a/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/test/team/actions/BranchAndResetActionTest.java b/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/test/team/actions/BranchAndResetActionTest.java
index 27bae49a9..980ba7663 100644
--- a/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/test/team/actions/BranchAndResetActionTest.java
+++ b/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/test/team/actions/BranchAndResetActionTest.java
@@ -202,8 +202,7 @@ public class BranchAndResetActionTest extends LocalRepositoryTestCase {
"Add to stable");
op.execute(null);
- InputStream is = toBeDeleted.getContents();
- try {
+ try (InputStream is = toBeDeleted.getContents()) {
checkout(new String[] { LOCAL_BRANCHES, "master" });
final SWTBotShell showUndeleted = bot
.shell(UIText.NonDeletedFilesDialog_NonDeletedFilesTitle);
@@ -282,8 +281,6 @@ public class BranchAndResetActionTest extends LocalRepositoryTestCase {
UIText.NonDeletedFilesDialog_RetryDeleteButton).click();
showUndeleted.bot().waitUntil(treeEmpty, 1000, 100);
showUndeleted.close();
- } finally {
- is.close();
}
}
diff --git a/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/test/team/actions/CompareActionsTest.java b/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/test/team/actions/CompareActionsTest.java
index 6be393b08..4229466dd 100644
--- a/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/test/team/actions/CompareActionsTest.java
+++ b/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/test/team/actions/CompareActionsTest.java
@@ -204,12 +204,12 @@ public class CompareActionsTest extends LocalRepositoryTestCase {
Ref newBranch = git.checkout().setCreateBranch(true)
.setStartPoint(commitOfTag.name()).setName("toMerge")
.call();
- ByteArrayInputStream bis = new ByteArrayInputStream(
- "Modified".getBytes("UTF-8"));
- ResourcesPlugin.getWorkspace().getRoot().getProject(PROJ1)
- .getFolder(FOLDER).getFile(FILE2)
- .setContents(bis, false, false, null);
- bis.close();
+ try (ByteArrayInputStream bis = new ByteArrayInputStream(
+ "Modified".getBytes("UTF-8"))) {
+ ResourcesPlugin.getWorkspace().getRoot().getProject(PROJ1)
+ .getFolder(FOLDER).getFile(FILE2)
+ .setContents(bis, false, false, null);
+ }
git.commit().setAll(true).setMessage("To be merged").call();
git.merge().include(masterId).call();
String menuLabel = util

Back to the top