This closes #2724
This commit is contained in:
commit
f964f955fa
|
@ -1,6 +1,8 @@
|
||||||
sudo: false
|
sudo: false
|
||||||
language: java
|
language: java
|
||||||
install: true
|
install: true
|
||||||
|
jdk:
|
||||||
|
- openjdk8
|
||||||
|
|
||||||
# clean out Artemis artifacts from the cache
|
# clean out Artemis artifacts from the cache
|
||||||
before_install:
|
before_install:
|
||||||
|
|
|
@ -1512,7 +1512,7 @@ public class PostOfficeImpl implements PostOffice, NotificationListener, Binding
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The expiry scanner can't be started until the whole server has been started other wise you may get races
|
* The expiry scanner can't be started until the whole server has been started other wise you may get races
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
|
@ -1601,10 +1601,10 @@ public class PostOfficeImpl implements PostOffice, NotificationListener, Binding
|
||||||
AddressSettings settings = addressSettingsRepository.getMatch(address.toString());
|
AddressSettings settings = addressSettingsRepository.getMatch(address.toString());
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if (addressInfo != null && !isAddressBound(address) && addressInfo.getBindingRemovedTimestamp() != -1 && (System.currentTimeMillis() - addressInfo.getBindingRemovedTimestamp() >= settings.getAutoDeleteAddressesDelay())) {
|
if (settings.isAutoDeleteAddresses() && addressInfo != null && addressInfo.isAutoCreated() && !isAddressBound(address) && addressInfo.getBindingRemovedTimestamp() != -1 && (System.currentTimeMillis() - addressInfo.getBindingRemovedTimestamp() >= settings.getAutoDeleteAddressesDelay())) {
|
||||||
|
|
||||||
if (ActiveMQServerLogger.LOGGER.isDebugEnabled()) {
|
if (ActiveMQServerLogger.LOGGER.isDebugEnabled()) {
|
||||||
ActiveMQServerLogger.LOGGER.info("deleting auto-created address \"" + address + ".\"");
|
ActiveMQServerLogger.LOGGER.debug("deleting auto-created address \"" + address + ".\"");
|
||||||
}
|
}
|
||||||
|
|
||||||
server.removeAddressInfo(address, null);
|
server.removeAddressInfo(address, null);
|
||||||
|
|
|
@ -163,6 +163,56 @@ public class AddressQueueDeleteDelayTest extends ActiveMQTestBase {
|
||||||
assertTrue(Wait.waitFor(() -> server.getAddressInfo(address) == null, DURATION_MILLIS, SLEEP_MILLIS));
|
assertTrue(Wait.waitFor(() -> server.getAddressInfo(address) == null, DURATION_MILLIS, SLEEP_MILLIS));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testAddressDeleteDelay() throws Exception {
|
||||||
|
SimpleString address = RandomUtil.randomSimpleString();
|
||||||
|
SimpleString queue = RandomUtil.randomSimpleString();
|
||||||
|
final long deleteAddressesDelay = 500;
|
||||||
|
|
||||||
|
AddressSettings addressSettings = new AddressSettings().setAutoDeleteAddressesDelay(deleteAddressesDelay);
|
||||||
|
server.getAddressSettingsRepository().addMatch(address.toString(), addressSettings);
|
||||||
|
|
||||||
|
session.createAddress(address, RoutingType.MULTICAST, true);
|
||||||
|
session.createQueue(address, RoutingType.MULTICAST, queue);
|
||||||
|
session.deleteQueue(queue);
|
||||||
|
|
||||||
|
assertTrue(Wait.waitFor(() -> server.getAddressInfo(address) == null, DURATION_MILLIS, SLEEP_MILLIS));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testAddressDeleteDelayNegative() throws Exception {
|
||||||
|
SimpleString address = RandomUtil.randomSimpleString();
|
||||||
|
SimpleString queue = RandomUtil.randomSimpleString();
|
||||||
|
final long deleteAddressesDelay = 500;
|
||||||
|
|
||||||
|
AddressSettings addressSettings = new AddressSettings().setAutoDeleteAddressesDelay(deleteAddressesDelay);
|
||||||
|
server.getAddressSettingsRepository().addMatch(address.toString(), addressSettings);
|
||||||
|
|
||||||
|
// the address should not be deleted since it is not auto-created
|
||||||
|
session.createAddress(address, RoutingType.MULTICAST, false);
|
||||||
|
session.createQueue(address, RoutingType.MULTICAST, queue);
|
||||||
|
session.deleteQueue(queue);
|
||||||
|
|
||||||
|
assertFalse(Wait.waitFor(() -> server.getAddressInfo(address) == null, DURATION_MILLIS, SLEEP_MILLIS));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testAddressDeleteDelayNegative2() throws Exception {
|
||||||
|
SimpleString address = RandomUtil.randomSimpleString();
|
||||||
|
SimpleString queue = RandomUtil.randomSimpleString();
|
||||||
|
final long deleteAddressesDelay = 500;
|
||||||
|
|
||||||
|
// the address should not be deleted since autoDeleteAddresses = false
|
||||||
|
AddressSettings addressSettings = new AddressSettings().setAutoDeleteAddressesDelay(deleteAddressesDelay).setAutoDeleteAddresses(false);
|
||||||
|
server.getAddressSettingsRepository().addMatch(address.toString(), addressSettings);
|
||||||
|
|
||||||
|
session.createAddress(address, RoutingType.MULTICAST, true);
|
||||||
|
session.createQueue(address, RoutingType.MULTICAST, queue);
|
||||||
|
session.deleteQueue(queue);
|
||||||
|
|
||||||
|
assertFalse(Wait.waitFor(() -> server.getAddressInfo(address) == null, DURATION_MILLIS, SLEEP_MILLIS));
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Before
|
@Before
|
||||||
public void setUp() throws Exception {
|
public void setUp() throws Exception {
|
||||||
|
|
Loading…
Reference in New Issue