private static @CheckForNull StepContext finish(@CheckForNull String cookie) {
if (cookie == null) {
return null;
}
synchronized (runningTasks) {
StepContext context = runningTasks.remove(cookie);
if (context == null) {
LOGGER.log(Level.FINE, "no running task corresponds to {0}", cookie);
}
runningTasks.notifyAll();
return context;