Program: 34828
Project: 34828
Buggy source:
private static void addEarToServer(LibertyServer server,String dir,String earName,boolean addEarResources,String warName,boolean addWarResources,String jarName,boolean addJarResources,String... packageNames) throws Exception {
  if (warName == null)   return;
  if (server.isStarted()) {
    String appName=warName.substring(0,warName.indexOf("String_Node_Str"));
    Set<String> appInstalled=server.getInstalledAppNames(appName);
    LOG.info("String_Node_Str" + appName + "String_Node_Str"+ !appInstalled.isEmpty());
    if (!appInstalled.isEmpty())     return;
  }
  JavaArchive jar=null;
  WebArchive war=null;
  if (jarName != null) {
    LOG.info("String_Node_Str" + jarName + "String_Node_Str"+ addJarResources);
    jar=ShrinkWrap.create(JavaArchive.class,jarName);
    if (packageNames != null) {
      for (      String packageName : packageNames) {
        if (packageName.contains("String_Node_Str")) {
          jar.addPackage(packageName);
        }
      }
    }
    if (addJarResources)     ShrinkHelper.addDirectory(jar,"String_Node_Str" + jarName + "String_Node_Str");
  }
  war=ShrinkWrap.create(WebArchive.class,warName);
  LOG.info("String_Node_Str" + warName + "String_Node_Str"+ addWarResources);
  if (packageNames != null) {
    for (    String packageName : packageNames) {
      if (packageName.contains("String_Node_Str")) {
        war.addPackage(packageName);
      }
    }
  }
  if (jar != null)   war.addAsLibrary(jar);
  if (addWarResources)   ShrinkHelper.addDirectory(war,"String_Node_Str" + warName + "String_Node_Str");
  boolean deploy=false;
  if (dir.equals(DIR_APPS) || dir.equals(DIR_DROPINS)) {
    deploy=true;
  }
  if (earName != null) {
    LOG.info("String_Node_Str" + earName + "String_Node_Str"+ addEarResources);
    EnterpriseArchive ear=ShrinkWrap.create(EnterpriseArchive.class,earName);
    ear.addAsModule(war);
    if (addEarResources) {
      ShrinkHelper.addDirectory(ear,"String_Node_Str" + earName + "String_Node_Str");
    }
    if (deploy) {
      ShrinkHelper.exportToServer(server,dir,ear);
    }
 else {
      ShrinkHelper.exportArtifact(ear,DIR_PUBLISH + server.getServerName() + "String_Node_Str"+ dir);
    }
  }
 else {
    if (deploy) {
      ShrinkHelper.exportToServer(server,dir,war);
    }
 else {
      ShrinkHelper.exportArtifact(war,DIR_PUBLISH + server.getServerName() + "String_Node_Str"+ dir);
    }
  }
}

Fixed version (ground truth):
private static void addEarToServer(LibertyServer server,String dir,String earName,boolean addEarResources,String warName,boolean addWarResources,String jarName,boolean addJarResources,String... packageNames) throws Exception {
  if (warName == null)   return;
  if (server.isStarted()) {
    String appName=warName.substring(0,warName.indexOf("String_Node_Str"));
    Set<String> appInstalled=server.getInstalledAppNames(appName);
    LOG.info("String_Node_Str" + appName + "String_Node_Str"+ !appInstalled.isEmpty());
    if (!appInstalled.isEmpty())     return;
  }
  JavaArchive jar=null;
  WebArchive war=null;
  if (jarName != null) {
    LOG.info("String_Node_Str" + jarName + "String_Node_Str"+ addJarResources);
    jar=ShrinkWrap.create(JavaArchive.class,jarName);
    if (packageNames != null) {
      for (      String packageName : packageNames) {
        if (packageName.contains("String_Node_Str")) {
          jar.addPackage(packageName);
        }
      }
    }
    if (addJarResources)     ShrinkHelper.addDirectory(jar,"String_Node_Str" + jarName + "String_Node_Str");
  }
  war=ShrinkWrap.create(WebArchive.class,warName);
  LOG.info("String_Node_Str" + warName + "String_Node_Str"+ addWarResources);
  if (packageNames != null) {
    for (    String packageName : packageNames) {
      if (packageName.contains("String_Node_Str")) {
        war.addPackage(packageName);
      }
    }
  }
  if (jar != null)   war.addAsLibrary(jar);
  if (addWarResources)   ShrinkHelper.addDirectory(war,"String_Node_Str" + warName + "String_Node_Str");
  boolean deploy=false;
  if (dir.equals(DIR_APPS) || dir.equals(DIR_DROPINS)) {
    deploy=true;
  }
  if (earName != null) {
    LOG.info("String_Node_Str" + earName + "String_Node_Str"+ addEarResources);
    EnterpriseArchive ear=ShrinkWrap.create(EnterpriseArchive.class,earName);
    ear.addAsModule(war);
    if (addEarResources) {
      ShrinkHelper.addDirectory(ear,"String_Node_Str" + earName + "String_Node_Str");
    }
    if (deploy) {
      deleteFileIfExist("String_Node_Str" + server.getServerName() + "String_Node_Str"+ dir+ "String_Node_Str"+ ear.getName());
      ShrinkHelper.exportToServer(server,dir,ear);
    }
 else {
      ShrinkHelper.exportArtifact(ear,DIR_PUBLISH + server.getServerName() + "String_Node_Str"+ dir,true,true);
    }
  }
 else {
    if (deploy) {
      deleteFileIfExist("String_Node_Str" + server.getServerName() + "String_Node_Str"+ dir+ "String_Node_Str"+ war.getName());
      ShrinkHelper.exportToServer(server,dir,war);
    }
 else {
      ShrinkHelper.exportArtifact(war,DIR_PUBLISH + server.getServerName() + "String_Node_Str"+ dir,true,true);
    }
  }
}