zone_data_ = load_action_(segment_->getMemorySegment());
+ if (zone_data_ == NULL) {
+ // Bug inside load_action_.
+ isc_throw(isc::Unexpected, "No data returned from load action");
+ }
+
data_ready_ = true;
}
/// This callback should create new ZoneData (allocated from the passed
/// memory segment) and fill it with relevant loaded data. The caller
/// of the callback takes ownership of the ZoneData.
+///
+/// It must not return NULL.
typedef boost::function<ZoneData*(util::MemorySegment&)> LoadAction;
/// \brief Install the zone somewhere.
///
load_called_(false),
install_called_(false),
load_throw_(false),
- install_throw_(false)
+ install_throw_(false),
+ load_null_(false)
{}
void TearDown() {
// Release the reloader
bool install_called_;
bool load_throw_;
bool install_throw_;
+ bool load_null_;
private:
ZoneData* loadAction(isc::util::MemorySegment& segment) {
// Make sure it is the correct segment passed. We know the
throw TestException();
}
+ if (load_null_) {
+ // Be nasty to the caller and return NULL, which is forbidden
+ return (NULL);
+ }
// Create a new zone data. It may be empty for our tests, nothing
// goes inside.
return (ZoneData::create(segment, Name("example.org")));
EXPECT_NO_THROW(reloader_->cleanup());
}
+// Check the reloader defends itsefl when load action returns NULL
+TEST_F(ZoneReloaderLocalTest, loadNull) {
+ load_null_ = true;
+ EXPECT_THROW(reloader_->load(), isc::Unexpected);
+
+ // We can't install that
+ EXPECT_THROW(reloader_->install(), isc::Unexpected);
+
+ // It should be possible to clean up safely
+ EXPECT_NO_THROW(reloader_->cleanup());
+}
+
}