diff options
author | Bananeweizen <bananeweizen@gmx.de> | 2014-03-04 20:25:12 +0100 |
---|---|---|
committer | Bananeweizen <bananeweizen@gmx.de> | 2014-03-04 20:25:12 +0100 |
commit | ea04b619e00a71a9b5a443511b28a82fe37dcead (patch) | |
tree | 49c156dc90f609609dd810d26dc1354d20f626cb /tests/src/cgeo/geocaching/test | |
parent | 2c7402bbc2da513eb16ea38dfda7edd7ee2f7996 (diff) | |
download | cgeo-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.java | 15 |
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 { |