spring-cloud-deployer-local
spring-cloud-deployer-local copied to clipboard
LocalTaskLauncher remove the instance from running map when task exits
LocalTaskLauncher does not remove intances from running map Map<String, TaskInstance> running = new ConcurrentHashMap<>(); Thus tasks created are added to the map, but not removed even cancelled. However LocalAppDeployer remove from map in cancel().
@Override
public void cancel(String id) {
TaskInstance instance = running.get(id);
if (instance != null) {
instance.cancelled = true;
if (isAlive(instance.getProcess())) {
shutdownAndWait(instance);
}
}
}
If you add running.remove(id) after shutdownAndwait it makes testSimpleCancel test case to be failed since getStatus return status as unknown when instance object is null.
assertThat(launchId, eventually(hasStatusThat(
Matchers.<TaskStatus>hasProperty("state", Matchers.is(LaunchState.running))), timeout.maxAttempts, timeout.pause));
@Override
public void cancel(String id) {
TaskInstance instance = running.get(id);
if (instance != null) {
instance.cancelled = true;
if (isAlive(instance.getProcess())) {
shutdownAndWait(instance);
}
running.remove(id);
}
}
Indeed this does sound like this is an issue to fix.