Module: check_mk
Branch: master
Commit: 7f795fdc66b36a18d91b6125238b02e74acc3081
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=7f795fdc66b36a…
Author: Sven Panne <sp(a)mathias-kettner.de>
Date: Mon Nov 20 09:49:35 2017 +0100
Introduce null object.
Change-Id: I4faa3c161f7b38e198e0d68c07aed015e563b35a
See:
https://refactoring.com/catalog/introduceNullObject.html
---
livestatus/src/CountAggregator.cc | 4 +---
livestatus/src/Query.cc | 4 ++++
2 files changed, 5 insertions(+), 3 deletions(-)
diff --git a/livestatus/src/CountAggregator.cc b/livestatus/src/CountAggregator.cc
index c9d589f..a7dd3cf 100644
--- a/livestatus/src/CountAggregator.cc
+++ b/livestatus/src/CountAggregator.cc
@@ -29,9 +29,7 @@
void CountAggregator::consume(Row row, const contact* auth_user,
std::chrono::seconds timezone_offset) {
- // _filter is 0 --> no filter, accept all rows
- if (_filter == nullptr ||
- _filter->accepts(row, auth_user, timezone_offset)) {
+ if (_filter->accepts(row, auth_user, timezone_offset)) {
_count++;
}
}
diff --git a/livestatus/src/Query.cc b/livestatus/src/Query.cc
index 7d7cde0..459fa19 100644
--- a/livestatus/src/Query.cc
+++ b/livestatus/src/Query.cc
@@ -330,6 +330,10 @@ void Query::parseStatsLine(char *line) {
throw std::runtime_error("missing value after operator");
}
filter = column->createFilter(relOp, value);
+ } else {
+ // create an "accept all" filter, just in case we fall back to
counting
+ filter = std::make_unique<AndingFilter>(
+ std::vector<std::unique_ptr<Filter>>());
}
_stats_columns.push_back(
std::make_unique<StatsColumn>(column.get(), move(filter), operation));