management: Controller allows empty callbacks
refs #3653
Change-Id: Id112960fa3f9f52854687b798c4632a922297ff2
diff --git a/src/management/nfd-controller.hpp b/src/management/nfd-controller.hpp
index 3ae1cf2..9fa721b 100644
--- a/src/management/nfd-controller.hpp
+++ b/src/management/nfd-controller.hpp
@@ -164,10 +164,15 @@
template<typename Dataset>
inline void
Controller::fetchDataset(shared_ptr<Dataset> dataset,
- const std::function<void(typename Dataset::ResultType)>& onSuccess,
- const CommandFailCallback& onFailure,
+ const std::function<void(typename Dataset::ResultType)>& onSuccess1,
+ const CommandFailCallback& onFailure1,
const CommandOptions& options)
{
+ const std::function<void(typename Dataset::ResultType)>& onSuccess = onSuccess1 ?
+ onSuccess1 : [] (const typename Dataset::ResultType&) {};
+ const CommandFailCallback& onFailure = onFailure1 ?
+ onFailure1 : [] (uint32_t, const std::string&) {};
+
Name prefix = dataset->getDatasetPrefix(options.getPrefix());
this->fetchDataset(prefix,
bind(&Controller::processDatasetResponse<Dataset>, this, dataset, onSuccess, onFailure, _1),
@@ -190,6 +195,7 @@
onFailure(ERROR_SERVER, ex.what());
return;
}
+
onSuccess(result);
}