changeset 41329:f79b4f079360

8166164: compiler/compilercontrol/share/processors/LogProcessor.java does not close Scanner Reviewed-by: kvn, ppunegov
author iignatyev
date Tue, 20 Sep 2016 17:30:33 +0300
parents 2bea535779f6
children 8b2580e63aa0
files hotspot/test/compiler/compilercontrol/share/processors/LogProcessor.java
diffstat 1 files changed, 16 insertions(+), 14 deletions(-) [+]
line wrap: on
line diff
--- a/hotspot/test/compiler/compilercontrol/share/processors/LogProcessor.java	Mon Sep 19 13:26:37 2016 -0700
+++ b/hotspot/test/compiler/compilercontrol/share/processors/LogProcessor.java	Tue Sep 20 17:30:33 2016 +0300
@@ -74,7 +74,7 @@
         if (loggedMethods.isEmpty()) {
             return;
         }
-        matchTasks(getScanner());
+        matchTasks();
     }
 
     /*
@@ -95,19 +95,21 @@
      * Parses for <task method='java.lang.String indexOf (I)I' >
      * and finds if there is a compilation log for this task
      */
-    private void matchTasks(Scanner scanner) {
-        String task = scanner.findWithinHorizon(TASK_ELEMENT, 0);
-        while (task != null) {
-            String element = scanner.findWithinHorizon(ANY_ELEMENT, 0);
-            if (Pattern.matches(TASK_DONE_ELEMENT, element)
-                    || Pattern.matches(TASK_END_ELEMENT, element)) {
-                /* If there is nothing between <task> and </task>
-                   except <task done /> then compilation log is empty.
-                   Check the method in this task should not be logged */
-                Asserts.assertFalse(matchMethod(task), "Compilation log "
-                        + "expected. Met: " + element);
-            }
-            task = scanner.findWithinHorizon(TASK_ELEMENT, 0);
+    private void matchTasks() {
+        try (Scanner scanner = getScanner()) {
+          String task = scanner.findWithinHorizon(TASK_ELEMENT, 0);
+          while (task != null) {
+              String element = scanner.findWithinHorizon(ANY_ELEMENT, 0);
+              if (Pattern.matches(TASK_DONE_ELEMENT, element)
+                      || Pattern.matches(TASK_END_ELEMENT, element)) {
+                  /* If there is nothing between <task> and </task>
+                     except <task done /> then compilation log is empty.
+                     Check the method in this task should not be logged */
+                  Asserts.assertFalse(matchMethod(task), "Compilation log "
+                          + "expected. Met: " + element);
+              }
+              task = scanner.findWithinHorizon(TASK_ELEMENT, 0);
+          }
         }
     }