spring-cloud-deployer-local icon indicating copy to clipboard operation
spring-cloud-deployer-local copied to clipboard

LocalTaskLauncher remove the instance from running map when task exits

Open udaraliyanage opened this issue 8 years ago • 1 comments

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);
		}
	}

udaraliyanage avatar Oct 04 '17 06:10 udaraliyanage

Indeed this does sound like this is an issue to fix.

markpollack avatar Mar 20 '18 21:03 markpollack