Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFlorian Waibel2015-05-22 04:26:24 -0400
committerFlorian Waibel2015-05-22 04:26:24 -0400
commit5d955f99f3d1c7e059bd29327b293bc7a28d6628 (patch)
treeaf6dcf0bcb9b09ed0cce40faa8d323338237df26 /org.eclipse.virgo.management.console
parent24eccaac1550a4572b9948d537a804deb4e0b4d9 (diff)
downloadorg.eclipse.virgo.kernel-5d955f99f3d1c7e059bd29327b293bc7a28d6628.tar.gz
org.eclipse.virgo.kernel-5d955f99f3d1c7e059bd29327b293bc7a28d6628.tar.xz
org.eclipse.virgo.kernel-5d955f99f3d1c7e059bd29327b293bc7a28d6628.zip
Fixes resource leak in Parser
Diffstat (limited to 'org.eclipse.virgo.management.console')
-rw-r--r--org.eclipse.virgo.management.console/src/main/java/org/eclipse/virgo/management/console/internal/Parser.java15
1 files changed, 8 insertions, 7 deletions
diff --git a/org.eclipse.virgo.management.console/src/main/java/org/eclipse/virgo/management/console/internal/Parser.java b/org.eclipse.virgo.management.console/src/main/java/org/eclipse/virgo/management/console/internal/Parser.java
index 08cabf09..de09da20 100644
--- a/org.eclipse.virgo.management.console/src/main/java/org/eclipse/virgo/management/console/internal/Parser.java
+++ b/org.eclipse.virgo.management.console/src/main/java/org/eclipse/virgo/management/console/internal/Parser.java
@@ -58,13 +58,14 @@ public class Parser {
* @param in
*/
public final void parse(InputStream in) throws IOException {
- Scanner scanner = new Scanner(in);
- String parsedLine;
- while (scanner.hasNextLine()) {
- parsedLine = parseLine(scanner.nextLine());
- if(parsedLine != null && !parsedLine.trim().isEmpty()){
- out.append(parsedLine);
- out.append('\n');
+ try (Scanner scanner = new Scanner(in)) {
+ String parsedLine;
+ while (scanner.hasNextLine()) {
+ parsedLine = parseLine(scanner.nextLine());
+ if (parsedLine != null && !parsedLine.trim().isEmpty()) {
+ out.append(parsedLine);
+ out.append('\n');
+ }
}
}
}

Back to the top