--- a/hotspot/src/share/vm/logging/logConfiguration.cpp Tue Apr 05 16:51:58 2016 +0200
+++ b/hotspot/src/share/vm/logging/logConfiguration.cpp Fri Aug 26 14:27:41 2016 +0200
@@ -243,6 +243,7 @@
}
void LogConfiguration::disable_output(size_t idx) {
+ assert(idx < _n_outputs, "invalid index: " SIZE_FORMAT " (_n_outputs: " SIZE_FORMAT ")", idx, _n_outputs);
LogOutput* out = _outputs[idx];
// Remove the output from all tagsets.
@@ -253,7 +254,7 @@
// Delete the output unless stdout/stderr
if (out != LogOutput::Stderr && out != LogOutput::Stdout) {
- delete_output(find_output(out->name()));
+ delete_output(idx);
} else {
out->set_config_string("all=off");
}
@@ -261,8 +262,8 @@
void LogConfiguration::disable_logging() {
ConfigurationLock cl;
- for (size_t i = 0; i < _n_outputs; i++) {
- disable_output(i);
+ for (size_t i = _n_outputs; i > 0; i--) {
+ disable_output(i - 1);
}
notify_update_listeners();
}
--- a/hotspot/test/native/logging/test_logConfiguration.cpp Tue Apr 05 16:51:58 2016 +0200
+++ b/hotspot/test/native/logging/test_logConfiguration.cpp Fri Aug 26 14:27:41 2016 +0200
@@ -164,10 +164,17 @@
// Add TestLogFileName as an output
set_log_config(TestLogFileName, "logging=info");
+ // Add a second file output
+ char other_file_name[2 * K];
+ jio_snprintf(other_file_name, sizeof(other_file_name), "%s-other", TestLogFileName);
+ set_log_config(other_file_name, "logging=info");
+
LogConfiguration::disable_logging();
- // Verify TestLogFileName was disabled
+ // Verify that both file outputs were disabled
EXPECT_FALSE(is_described(TestLogFileName));
+ EXPECT_FALSE(is_described(other_file_name));
+ delete_file(other_file_name);
// Verify that no tagset has logging enabled
for (LogTagSet* ts = LogTagSet::first(); ts != NULL; ts = ts->next()) {