Commit 63c8beeb authored by JINMEI Tatuya's avatar JINMEI Tatuya
Browse files

[2833] throw CacheConfigError for duplicate zone names.

this is not a program error, so CacheConfigError should be more appropriate.
parent d9f12c0e
......@@ -101,7 +101,7 @@ CacheConfig::CacheConfig(const std::string& datasrc_type,
const dns::Name zone_name(zones->get(i)->stringValue());
if (!zone_config_.insert(Zones::value_type(zone_name,
"")).second) {
isc_throw(InvalidParameter, "Duplicate cache zone: " <<
isc_throw(CacheConfigError, "Duplicate cache zone: " <<
zone_name);
}
}
......
......@@ -91,6 +91,8 @@ public:
/// - Each string value of cache-zones entries must be a valid textual
/// representation of a domain name. Otherwise corresponding
/// exception from the dns::Name class will be thrown.
/// - Names in the list must not have duplicates;
/// throws CacheConfigError otherwise.
///
/// For other data source types than "MasterFiles", cache can be disabled.
/// In this case cache-zones configuration item is simply ignored, even
......@@ -105,11 +107,11 @@ public:
/// item if defined; otherwise it defaults to "local".
///
/// \throw InvalidParameter Program error at the caller side rather than
/// in the configuration.
/// in the configuration (see above)
/// \throw CacheConfigError There is a semantics error in the given
/// configuration.
/// configuration (see above)
/// \throw data::TypeError There is a syntax error in the given
/// configuration.
/// configuration (see above)
///
/// \param datasrc_type Type of data source. This must be the "type"
/// value of the data source configuration.
......
......@@ -204,13 +204,13 @@ TEST_F(CacheConfigTest, badConstructWithMock) {
EXPECT_THROW(CacheConfig("mock", &mock_client_, *bad_config, true),
isc::dns::EmptyLabel);
// duplicate zone name
// duplicate zone name (note that comparison is case insensitive)
const ConstElementPtr dup_config(Element::fromJSON(
"{\"cache-enable\": true,"
" \"cache-zones\": "
" [\"example\", \"example\"]}"));
" [\"example\", \"EXAMPLE\"]}"));
EXPECT_THROW(CacheConfig("mock", &mock_client_, *dup_config, true),
isc::InvalidParameter);
CacheConfigError);
// datasrc is null
EXPECT_THROW(CacheConfig("mock", 0, *mock_config_, true),
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment