diff --git a/activemq-broker/src/main/java/org/apache/activemq/broker/region/RegionBroker.java b/activemq-broker/src/main/java/org/apache/activemq/broker/region/RegionBroker.java index da6b4dcc50..aa0909d4b3 100644 --- a/activemq-broker/src/main/java/org/apache/activemq/broker/region/RegionBroker.java +++ b/activemq-broker/src/main/java/org/apache/activemq/broker/region/RegionBroker.java @@ -913,7 +913,7 @@ public class RegionBroker extends EmptyBroker { log.info("{} Inactive for longer than {} ms - removing ...", dest.getName(), dest.getInactiveTimeoutBeforeGC()); try { getRoot().removeDestination(context, dest.getActiveMQDestination(), isAllowTempAutoCreationOnSend() ? 1 : 0); - } catch (Exception e) { + } catch (Throwable e) { LOG.error("Failed to remove inactive destination {}", dest, e); } } diff --git a/activemq-unit-tests/src/test/java/org/apache/activemq/broker/region/DestinationGCStressTest.java b/activemq-unit-tests/src/test/java/org/apache/activemq/broker/region/DestinationGCStressTest.java index c6f8409c62..c23c65afc3 100644 --- a/activemq-unit-tests/src/test/java/org/apache/activemq/broker/region/DestinationGCStressTest.java +++ b/activemq-unit-tests/src/test/java/org/apache/activemq/broker/region/DestinationGCStressTest.java @@ -22,6 +22,7 @@ import org.apache.activemq.broker.region.policy.PolicyEntry; import org.apache.activemq.broker.region.policy.PolicyMap; import org.apache.activemq.command.ActiveMQTopic; import org.apache.activemq.util.DefaultTestAppender; +import org.apache.activemq.util.Wait; import org.apache.log4j.Appender; import org.apache.log4j.Level; import org.apache.log4j.spi.LoggingEvent; @@ -169,7 +170,7 @@ public class DestinationGCStressTest { log4jLogger.addAppender(appender); try { - final AtomicInteger max = new AtomicInteger(20000); + final AtomicInteger max = new AtomicInteger(10000); final ActiveMQConnectionFactory factory = new ActiveMQConnectionFactory("vm://localhost?create=false"); factory.setWatchTopicAdvisories(false); @@ -218,6 +219,16 @@ public class DestinationGCStressTest { logger.info("Done"); + + Wait.waitFor(new Wait.Condition() { + @Override + public boolean isSatisified() throws Exception { + int len = ((RegionBroker)brokerService.getRegionBroker()).getTopicRegion().getDestinationMap().size(); + logger.info("Num topics: " + len); + return len == 0; + } + }); + connection.close(); } finally {