Browse Source

[2098] make sure unexpected method call doesn't happen by exception/assert

JINMEI Tatuya 12 years ago
parent
commit
e8ec4c911e

+ 1 - 0
src/lib/datasrc/memory/rdata_serialization.cc

@@ -250,6 +250,7 @@ public:
     virtual void setCompressMode(CompressMode) {}
     virtual void writeName(const LabelSequence&, bool) {
         // We don't need this version of writeName
+        isc_throw(Unexpected, "unexpected version of writeName is called");
     }
 
     // Called for each domain name in the RDATA, from the RDATA's toWire()

+ 5 - 1
src/lib/dns/benchmarks/message_renderer_bench.cc

@@ -116,7 +116,11 @@ public:
     virtual void writeName(const Name& name, const bool = false) {
         name.toWire(getBuffer());
     }
-    virtual void writeName(const LabelSequence&, const bool) {} // unused
+    virtual void writeName(const LabelSequence&, const bool) {
+        // We shouldn't use this version of writeName (and we internally
+        // control it, so we simply assert it here)
+        assert(false);
+    }
 };
 
 void

+ 3 - 1
src/lib/dns/benchmarks/oldmessagerenderer.cc

@@ -277,7 +277,9 @@ OldMessageRenderer::writeName(const Name& name, const bool compress) {
 
 void
 OldMessageRenderer::writeName(const LabelSequence&, const bool) {
-    // we don't use this mode for the benchmark
+    // We shouldn't use this version of writeName (and we internally
+    // control it, so we simply assert it here)
+    assert(false);
 }
 
 }