diff options
| author | Keith Wall <kwall@apache.org> | 2013-08-04 14:05:23 +0000 |
|---|---|---|
| committer | Keith Wall <kwall@apache.org> | 2013-08-04 14:05:23 +0000 |
| commit | 74e52755fa4a170affef6713f291163e0d0ef312 (patch) | |
| tree | 7670b6abaa89b8a2298d1d49dbf9ddaedbb2d86a /qpid/java/broker/src | |
| parent | bfa5d45dbb9f07c074471328c3d7c86b826b7705 (diff) | |
| download | qpid-python-74e52755fa4a170affef6713f291163e0d0ef312.tar.gz | |
QPID-5038: [Java Broker Tests] Fix leak from message store tests
Ensure that all message store tests close the message store under test on all code paths. This prevents a BDB thread leak manifesting
when running a BDB profile.
git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@1510189 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'qpid/java/broker/src')
2 files changed, 29 insertions, 42 deletions
diff --git a/qpid/java/broker/src/test/java/org/apache/qpid/server/store/AbstractDurableConfigurationStoreTestCase.java b/qpid/java/broker/src/test/java/org/apache/qpid/server/store/AbstractDurableConfigurationStoreTestCase.java index 62c731b2ec..ab1a0f7d0c 100644 --- a/qpid/java/broker/src/test/java/org/apache/qpid/server/store/AbstractDurableConfigurationStoreTestCase.java +++ b/qpid/java/broker/src/test/java/org/apache/qpid/server/store/AbstractDurableConfigurationStoreTestCase.java @@ -116,8 +116,16 @@ public abstract class AbstractDurableConfigurationStoreTestCase extends QpidTest public void tearDown() throws Exception { - FileUtils.delete(new File(_storePath), true); - super.tearDown(); + try + { + closeMessageStore(); + closeConfigStore(); + FileUtils.delete(new File(_storePath), true); + } + finally + { + super.tearDown(); + } } public void testCreateExchange() throws Exception @@ -366,11 +374,8 @@ public abstract class AbstractDurableConfigurationStoreTestCase extends QpidTest private void reopenStore() throws Exception { - onReopenStore(); - if (_messageStore != null) - { - _messageStore.close(); - } + closeMessageStore(); + closeConfigStore(); _messageStore = createMessageStore(); _configStore = createConfigStore(); @@ -379,40 +384,11 @@ public abstract class AbstractDurableConfigurationStoreTestCase extends QpidTest _messageStore.activate(); } - protected abstract void onReopenStore(); + protected abstract MessageStore createMessageStore() throws Exception; + protected abstract DurableConfigurationStore createConfigStore() throws Exception; + protected abstract void closeMessageStore() throws Exception; + protected abstract void closeConfigStore() throws Exception; - abstract protected MessageStore createMessageStore() throws Exception; - /*{ - String storeClass = System.getProperty(MESSAGE_STORE_CLASS_NAME_KEY); - if (storeClass == null) - { - storeClass = DerbyMessageStore.class.getName(); - } - CurrentActor.set(new TestLogActor(new SystemOutMessageLogger())); - MessageStore messageStore = (MessageStore) Class.forName(storeClass).newInstance(); - return messageStore; - } -*/ - abstract protected DurableConfigurationStore createConfigStore() throws Exception; - /*{ - String storeClass = System.getProperty(CONFIGURATION_STORE_CLASS_NAME_KEY); - if (storeClass == null) - { - storeClass = DerbyMessageStore.class.getName(); - } - Class<DurableConfigurationStore> clazz = (Class<DurableConfigurationStore>) Class.forName(storeClass); - DurableConfigurationStore configurationStore ; - if(clazz.isInstance(_messageStore)) - { - configurationStore = (DurableConfigurationStore) _messageStore; - } - else - { - configurationStore = (DurableConfigurationStore) Class.forName(storeClass).newInstance(); - } - return configurationStore; - } -*/ public void testRecordXid() throws Exception { Record enqueueRecord = getTestRecord(1); diff --git a/qpid/java/broker/src/test/java/org/apache/qpid/server/store/MessageStoreQuotaEventsTestBase.java b/qpid/java/broker/src/test/java/org/apache/qpid/server/store/MessageStoreQuotaEventsTestBase.java index 4a246b018b..ea47be83ec 100644 --- a/qpid/java/broker/src/test/java/org/apache/qpid/server/store/MessageStoreQuotaEventsTestBase.java +++ b/qpid/java/broker/src/test/java/org/apache/qpid/server/store/MessageStoreQuotaEventsTestBase.java @@ -70,6 +70,7 @@ public abstract class MessageStoreQuotaEventsTestBase extends QpidTestCase imple _store = createStore(); ((DurableConfigurationStore)_store).configureConfigStore("test", null, vhost); + _store.configureMessageStore("test", null, null); _transactionResource = UUID.randomUUID(); _events = new ArrayList<Event>(); @@ -79,8 +80,18 @@ public abstract class MessageStoreQuotaEventsTestBase extends QpidTestCase imple @Override public void tearDown() throws Exception { - super.tearDown(); - FileUtils.delete(_storeLocation, true); + try + { + super.tearDown(); + } + finally + { + if (_store != null) + { + _store.close(); + } + FileUtils.delete(_storeLocation, true); + } } public void testOverflow() throws Exception |
