From 8b366b300133e13d933e93490debb09e6f362899 Mon Sep 17 00:00:00 2001 From: Mark McLoughlin Date: Wed, 31 Jul 2013 08:04:11 +0100 Subject: [PATCH] Pop _unique_id when checking for duplicates Drivers should not be returning messages with any driver-specific wire format fields included. Right now, the rabbit and qpid drivers are leaking the _unique_id field. Avoid this simply by popping _unique_id when we're checking for dups. Change-Id: Icbfb02ee66aebe5ef97a9a2502d8a0745e07bd8b --- oslo/messaging/_drivers/amqp.py | 2 +- tests/test_rabbit.py | 3 --- 2 files changed, 1 insertion(+), 4 deletions(-) diff --git a/oslo/messaging/_drivers/amqp.py b/oslo/messaging/_drivers/amqp.py index 287878721..95a84f17e 100644 --- a/oslo/messaging/_drivers/amqp.py +++ b/oslo/messaging/_drivers/amqp.py @@ -323,7 +323,7 @@ class _MsgIdCache(object): before ack is returned. This method prevents doing it. """ if UNIQUE_ID in message_data: - msg_id = message_data[UNIQUE_ID] + msg_id = message_data.pop(UNIQUE_ID) if msg_id not in self.prev_msgids: self.prev_msgids.append(msg_id) else: diff --git a/tests/test_rabbit.py b/tests/test_rabbit.py index 3cb2203da..e6de418bd 100644 --- a/tests/test_rabbit.py +++ b/tests/test_rabbit.py @@ -52,7 +52,4 @@ class TestRabbitDriver(test_utils.BaseTestCase): received = listener.poll() self.assertTrue(received is not None) self.assertEquals(received.ctxt, {}) - - # FIXME(markmc): this should be done by the driver - received.message.pop('_unique_id') self.assertEquals(received.message, {'foo': 'bar'})