# HG changeset patch
# User iignatyev
# Date 1474381833 -10800
# Node ID f79b4f0793608b5b26e7365edad67c7a36033b14
# Parent 2bea535779f6cbca19a7b55cf179513bb502dcb3
8166164: compiler/compilercontrol/share/processors/LogProcessor.java does not close Scanner
Reviewed-by: kvn, ppunegov
diff -r 2bea535779f6 -r f79b4f079360 hotspot/test/compiler/compilercontrol/share/processors/LogProcessor.java
--- 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 and
- except 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 and
+ except 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);
+ }
}
}