aboutsummaryrefslogtreecommitdiffstats
path: root/tests/src/cgeo/geocaching/test
diff options
context:
space:
mode:
authorBananeweizen <bananeweizen@gmx.de>2014-03-04 20:25:12 +0100
committerBananeweizen <bananeweizen@gmx.de>2014-03-04 20:25:12 +0100
commitea04b619e00a71a9b5a443511b28a82fe37dcead (patch)
tree49c156dc90f609609dd810d26dc1354d20f626cb /tests/src/cgeo/geocaching/test
parent2c7402bbc2da513eb16ea38dfda7edd7ee2f7996 (diff)
downloadcgeo-ea04b619e00a71a9b5a443511b28a82fe37dcead.zip
cgeo-ea04b619e00a71a9b5a443511b28a82fe37dcead.tar.gz
cgeo-ea04b619e00a71a9b5a443511b28a82fe37dcead.tar.bz2
resource not closed in test
Diffstat (limited to 'tests/src/cgeo/geocaching/test')
-rw-r--r--tests/src/cgeo/geocaching/test/AbstractResourceInstrumentationTestCase.java15
1 files changed, 10 insertions, 5 deletions
diff --git a/tests/src/cgeo/geocaching/test/AbstractResourceInstrumentationTestCase.java b/tests/src/cgeo/geocaching/test/AbstractResourceInstrumentationTestCase.java
index 12e83cc..e4f8ca5 100644
--- a/tests/src/cgeo/geocaching/test/AbstractResourceInstrumentationTestCase.java
+++ b/tests/src/cgeo/geocaching/test/AbstractResourceInstrumentationTestCase.java
@@ -36,14 +36,19 @@ public abstract class AbstractResourceInstrumentationTestCase extends Instrument
}
protected String getFileContent(int resourceId) {
- final InputStream ins = getResourceStream(resourceId);
- final String result = new Scanner(ins).useDelimiter("\\A").next();
+ Scanner scanner = null;
try {
- ins.close();
- } catch (IOException e) {
+ final InputStream ins = getResourceStream(resourceId);
+ scanner = new Scanner(ins);
+ return scanner.useDelimiter("\\A").next();
+ } catch (Exception e) {
e.printStackTrace();
+ } finally {
+ if (scanner != null) {
+ scanner.close();
+ }
}
- return result;
+ return null;
}
protected void copyResourceToFile(int resourceId, File file) throws IOException {