Program: 151526
Project: 151526
Buggy source:
@Override public Forge start(ClassLoader loader){
  assertNotAlive();
  this.loader=loader;
  fireBeforeContainerStartedEvent(loader);
  if (!alive) {
    try {
      alive=true;
      do {
        boolean dirty=false;
        if (!isStartingAddons()) {
          for (          AddonRepository repository : repositories) {
            int repoVersion=repository.getVersion();
            if (repoVersion > lastRepoVersionSeen.get(repository)) {
              lastRepoVersionSeen.put(repository,repoVersion);
              dirty=true;
              for (              Addon addon : registry.getAddons()) {
                boolean enabled=false;
                if (repository.isEnabled(addon.getId())) {
                  enabled=true;
                }
                if (!enabled && addon.getStatus().isStarted()) {
                  try {
                    registry.stop(addon);
                  }
 catch (                  Exception e) {
                    logger.log(Level.SEVERE,"String_Node_Str",e);
                  }
                }
              }
            }
          }
          if (dirty) {
            try {
              registry.startAll();
            }
 catch (            Exception e) {
              logger.log(Level.SEVERE,"String_Node_Str",e);
            }
          }
        }
        Thread.sleep(100);
      }
 while (alive && serverMode);
      while (alive && isStartingAddons()) {
        Thread.sleep(100);
      }
    }
 catch (    Exception e) {
      logger.log(Level.SEVERE,"String_Node_Str",e);
    }
 finally {
      fireBeforeContainerStoppedEvent(loader);
      registry.stopAll();
    }
  }
  fireAfterContainerStoppedEvent(loader);
  return this;
}

Fixed version (ground truth):
@Override public Forge start(ClassLoader loader){
  assertNotAlive();
  this.loader=loader;
  for (  ContainerLifecycleListener listener : ServiceLoader.load(ContainerLifecycleListener.class,loader)) {
    ListenerRegistration<ContainerLifecycleListener> registration=addContainerLifecycleListener(listener);
    loadedListenerRegistrations.add(registration);
  }
  fireBeforeContainerStartedEvent(loader);
  if (!alive) {
    try {
      alive=true;
      do {
        boolean dirty=false;
        if (!isStartingAddons()) {
          for (          AddonRepository repository : repositories) {
            int repoVersion=repository.getVersion();
            if (repoVersion > lastRepoVersionSeen.get(repository)) {
              lastRepoVersionSeen.put(repository,repoVersion);
              dirty=true;
              for (              Addon addon : registry.getAddons()) {
                boolean enabled=false;
                if (repository.isEnabled(addon.getId())) {
                  enabled=true;
                }
                if (!enabled && addon.getStatus().isStarted()) {
                  try {
                    registry.stop(addon);
                  }
 catch (                  Exception e) {
                    logger.log(Level.SEVERE,"String_Node_Str",e);
                  }
                }
              }
            }
          }
          if (dirty) {
            try {
              registry.startAll();
            }
 catch (            Exception e) {
              logger.log(Level.SEVERE,"String_Node_Str",e);
            }
          }
        }
        Thread.sleep(100);
      }
 while (alive && serverMode);
      while (alive && isStartingAddons()) {
        Thread.sleep(100);
      }
    }
 catch (    Exception e) {
      logger.log(Level.SEVERE,"String_Node_Str",e);
    }
 finally {
      fireBeforeContainerStoppedEvent(loader);
      registry.stopAll();
    }
  }
  fireAfterContainerStoppedEvent(loader);
  for (  ListenerRegistration<ContainerLifecycleListener> registation : loadedListenerRegistrations) {
    registation.removeListener();
  }
  return this;
}