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.core.test/src
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.core.test/src')
-rw-r--r--org.eclipse.egit.core.test/src/org/eclipse/egit/core/test/models/ModelTestCase.java19
1 files changed, 10 insertions, 9 deletions
diff --git a/org.eclipse.egit.core.test/src/org/eclipse/egit/core/test/models/ModelTestCase.java b/org.eclipse.egit.core.test/src/org/eclipse/egit/core/test/models/ModelTestCase.java
index a66dae237..fcf0d5559 100644
--- a/org.eclipse.egit.core.test/src/org/eclipse/egit/core/test/models/ModelTestCase.java
+++ b/org.eclipse.egit.core.test/src/org/eclipse/egit/core/test/models/ModelTestCase.java
@@ -81,16 +81,17 @@ public abstract class ModelTestCase extends GitTestCase {
protected void assertContentEquals(IFile file, String expectedContents)
throws Exception {
- BufferedReader reader = new BufferedReader(new InputStreamReader(
- file.getContents(), file.getCharset()));
- StringBuilder contentsBuilder = new StringBuilder();
- String line = reader.readLine();
- while (line != null) {
- contentsBuilder.append(line);
- contentsBuilder.append('\n');
- line = reader.readLine();
+ StringBuilder contentsBuilder;
+ try (BufferedReader reader = new BufferedReader(new InputStreamReader(
+ file.getContents(), file.getCharset()))) {
+ contentsBuilder = new StringBuilder();
+ String line = reader.readLine();
+ while (line != null) {
+ contentsBuilder.append(line);
+ contentsBuilder.append('\n');
+ line = reader.readLine();
+ }
}
- reader.close();
assertEquals(expectedContents, contentsBuilder.toString());
}

Back to the top