Program: 69084
Project: 69084
Buggy source:
public LoadBalancer createLoadBalancer(EcsClusterMetadata clusterMetadata,EcsPushDefinition definition){
  String appName=definition.getAppName();
  EcsPortHandler portHandler=new EcsPortHandler();
  String protocol=definition.getService().getProtocol();
  if (protocol == null) {
    protocol=HTTPS;
  }
  String urlPrefix=appName;
  if (definition.getService().getUrlPrefixOverride() != null) {
    urlPrefix=definition.getService().getUrlPrefixOverride();
  }
  String urlSuffix=definition.getService().getUrlSuffix();
  DeriveCertResult deriveCertResult=certHandler.deriveCert(protocol,urlSuffix,urlPrefix);
  ContainerDefinition webContainer=portHandler.findContainerWithExposedPort(definition,false);
  Integer randomPort=webContainer.getPortMappings().get(0).getHostPort();
  Integer containerPort=webContainer.getPortMappings().get(0).getContainerPort();
  String containerName=webContainer.getName();
  boolean isInternetFacingUrlScheme=certHandler.isInternetFacingUrlScheme(deriveCertResult.getSslCertificate(),definition.getService().getUrlSchemeOverride());
  boolean isUsingInternalSubnets=true;
  String elbScheme;
  List<String> elbSubnets;
  if (isInternetFacingUrlScheme || "String_Node_Str".equals(definition.getService().getElbSchemeOverride())) {
    elbScheme="String_Node_Str";
    isUsingInternalSubnets=false;
    elbSubnets=clusterMetadata.getPublicSubnets();
  }
 else {
    elbScheme="String_Node_Str";
    elbSubnets=clusterMetadata.getElbSubnets();
  }
  List<String> elbSecurityGroups=new ArrayList<>();
  if (isInternetFacingUrlScheme && HTTPS.equals(protocol)) {
    elbSecurityGroups.addAll(clusterMetadata.getAkamaiSecurityGroup());
  }
 else {
    elbSecurityGroups.addAll(clusterMetadata.getElbSecurityGroups());
  }
  List<Listener> listeners=generateListeners(definition.getService().getElbSourcePorts(),randomPort,protocol,deriveCertResult.getCertArn());
  List<com.amazonaws.services.elasticloadbalancing.model.Tag> tags=getElbTagList(clusterMetadata.getClusterCftStackTags(),appName);
  try {
    elbClient.createLoadBalancer(new CreateLoadBalancerRequest().withSubnets(elbSubnets).withListeners(listeners).withScheme(elbScheme).withSecurityGroups(elbSecurityGroups).withLoadBalancerName(appName).withTags(tags));
  }
 catch (  DuplicateLoadBalancerNameException e) {
    LOGGER.debug("String_Node_Str" + appName,e);
    buildLogger.addBuildLogEntry("String_Node_Str" + appName);
    elbClient.deleteLoadBalancerListeners(new DeleteLoadBalancerListenersRequest().withLoadBalancerName(appName).withLoadBalancerPorts(CollectionUtils.isNotEmpty(definition.getService().getElbSourcePorts()) ? definition.getService().getElbSourcePorts() : Arrays.asList(443)));
    elbClient.createLoadBalancerListeners(new CreateLoadBalancerListenersRequest().withListeners(listeners).withLoadBalancerName(appName));
    elbClient.applySecurityGroupsToLoadBalancer(new ApplySecurityGroupsToLoadBalancerRequest().withLoadBalancerName(appName).withSecurityGroups(elbSecurityGroups));
    elbClient.addTags(new AddTagsRequest().withLoadBalancerNames(appName).withTags(tags));
    elbClient.attachLoadBalancerToSubnets(new AttachLoadBalancerToSubnetsRequest().withSubnets(elbSubnets).withLoadBalancerName(appName));
  }
  if (definition.getService().getAppStickinessCookie() != null) {
    elbClient.createAppCookieStickinessPolicy(new CreateAppCookieStickinessPolicyRequest().withLoadBalancerName(appName).withPolicyName("String_Node_Str").withCookieName(definition.getService().getAppStickinessCookie()));
    elbClient.setLoadBalancerPoliciesOfListener(new SetLoadBalancerPoliciesOfListenerRequest().withLoadBalancerName(appName).withLoadBalancerPort(443).withPolicyNames("String_Node_Str"));
  }
  HealthCheck healthCheck=definition.getService().getHealthCheck();
  String healthCheckPath=healthCheck.getTarget();
  if ("String_Node_Str".equals(healthCheckPath)) {
    healthCheckPath="String_Node_Str" + randomPort;
  }
 else {
    healthCheckPath="String_Node_Str" + randomPort + healthCheckPath;
  }
  healthCheck.setTarget(healthCheckPath);
  if (healthCheck.getInterval() == null) {
    healthCheck.setInterval(30);
  }
  if (healthCheck.getHealthyThreshold() == null) {
    healthCheck.setHealthyThreshold(2);
  }
  if (healthCheck.getTimeout() == null) {
    healthCheck.setTimeout(10);
  }
  if (healthCheck.getUnhealthyThreshold() == null) {
    healthCheck.setUnhealthyThreshold(10);
  }
  elbClient.configureHealthCheck(new ConfigureHealthCheckRequest().withLoadBalancerName(appName).withHealthCheck(healthCheck));
  DescribeLoadBalancersResult elbResult=elbClient.describeLoadBalancers(new DescribeLoadBalancersRequest().withLoadBalancerNames(appName));
  LoadBalancerDescription elbDesc=elbResult.getLoadBalancerDescriptions().get(0);
  String registeredUrl=urlPrefix + "String_Node_Str" + definition.getService().getUrlSuffix();
  if (isUsingInternalSubnets) {
    dnsRegistrar.registerDns(registeredUrl,elbDesc.getDNSName(),appName,clusterMetadata.getClusterCftStackTags());
    buildLogger.addBuildLogEntry("String_Node_Str" + protocol.toLowerCase() + "String_Node_Str"+ registeredUrl);
  }
 else {
    buildLogger.addBuildLogEntry("String_Node_Str" + protocol.toLowerCase() + "String_Node_Str"+ elbDesc.getDNSName());
    buildLogger.addBuildLogEntry("String_Node_Str" + protocol.toLowerCase() + "String_Node_Str"+ registeredUrl);
  }
  buildLogger.addBuildLogEntry("String_Node_Str");
  return new LoadBalancer().withContainerName(containerName).withContainerPort(containerPort).withLoadBalancerName(appName);
}

Fixed version (ground truth):
public LoadBalancer createLoadBalancer(EcsClusterMetadata clusterMetadata,EcsPushDefinition definition){
  String appName=definition.getAppName();
  EcsPortHandler portHandler=new EcsPortHandler();
  String protocol=definition.getService().getProtocol();
  if (protocol == null) {
    protocol=HTTPS;
  }
  String urlPrefix=appName;
  if (definition.getService().getUrlPrefixOverride() != null) {
    urlPrefix=definition.getService().getUrlPrefixOverride();
  }
  String urlSuffix=definition.getService().getUrlSuffix();
  DeriveCertResult deriveCertResult=certHandler.deriveCert(protocol,urlSuffix,urlPrefix);
  ContainerDefinition webContainer=portHandler.findContainerWithExposedPort(definition,false);
  Integer randomPort=webContainer.getPortMappings().get(0).getHostPort();
  Integer containerPort=webContainer.getPortMappings().get(0).getContainerPort();
  String containerName=webContainer.getName();
  boolean isInternetFacingUrlScheme=certHandler.isInternetFacingUrlScheme(deriveCertResult.getSslCertificate(),definition.getService().getUrlSchemeOverride());
  boolean isUsingInternalSubnets=true;
  String elbScheme;
  List<String> elbSubnets;
  if (isInternetFacingUrlScheme || "String_Node_Str".equals(definition.getService().getElbSchemeOverride())) {
    elbScheme="String_Node_Str";
    isUsingInternalSubnets=false;
    elbSubnets=clusterMetadata.getPublicSubnets();
  }
 else {
    elbScheme="String_Node_Str";
    elbSubnets=clusterMetadata.getElbSubnets();
  }
  List<String> elbSecurityGroups=new ArrayList<>();
  if (isInternetFacingUrlScheme && HTTPS.equals(protocol)) {
    elbSecurityGroups.addAll(clusterMetadata.getAkamaiSecurityGroup());
  }
 else {
    elbSecurityGroups.addAll(clusterMetadata.getElbSecurityGroups());
  }
  List<Listener> listeners=generateListeners(definition.getService().getElbSourcePorts(),randomPort,protocol,deriveCertResult.getCertArn());
  List<com.amazonaws.services.elasticloadbalancing.model.Tag> tags=getElbTagList(clusterMetadata.getClusterCftStackTags(),appName);
  CreateLoadBalancerRequest createLoadBalancerRequest=new CreateLoadBalancerRequest().withSubnets(elbSubnets).withListeners(listeners).withScheme(elbScheme).withSecurityGroups(elbSecurityGroups).withLoadBalancerName(appName).withTags(tags);
  try {
    elbClient.createLoadBalancer(createLoadBalancerRequest);
  }
 catch (  DuplicateLoadBalancerNameException e) {
    LOGGER.debug("String_Node_Str" + appName,e);
    buildLogger.addBuildLogEntry("String_Node_Str" + appName);
    elbClient.deleteLoadBalancerListeners(new DeleteLoadBalancerListenersRequest().withLoadBalancerName(appName).withLoadBalancerPorts(CollectionUtils.isNotEmpty(definition.getService().getElbSourcePorts()) ? definition.getService().getElbSourcePorts() : Arrays.asList(443)));
    elbClient.createLoadBalancerListeners(new CreateLoadBalancerListenersRequest().withListeners(listeners).withLoadBalancerName(appName));
    elbClient.applySecurityGroupsToLoadBalancer(new ApplySecurityGroupsToLoadBalancerRequest().withLoadBalancerName(appName).withSecurityGroups(elbSecurityGroups));
    elbClient.addTags(new AddTagsRequest().withLoadBalancerNames(appName).withTags(tags));
    elbClient.attachLoadBalancerToSubnets(new AttachLoadBalancerToSubnetsRequest().withSubnets(elbSubnets).withLoadBalancerName(appName));
  }
catch (  Exception ex) {
    throw new RuntimeException("String_Node_Str" + createLoadBalancerRequest);
  }
  if (definition.getService().getAppStickinessCookie() != null) {
    elbClient.createAppCookieStickinessPolicy(new CreateAppCookieStickinessPolicyRequest().withLoadBalancerName(appName).withPolicyName("String_Node_Str").withCookieName(definition.getService().getAppStickinessCookie()));
    elbClient.setLoadBalancerPoliciesOfListener(new SetLoadBalancerPoliciesOfListenerRequest().withLoadBalancerName(appName).withLoadBalancerPort(443).withPolicyNames("String_Node_Str"));
  }
  HealthCheck healthCheck=definition.getService().getHealthCheck();
  String healthCheckPath=healthCheck.getTarget();
  if ("String_Node_Str".equals(healthCheckPath)) {
    healthCheckPath="String_Node_Str" + randomPort;
  }
 else {
    healthCheckPath="String_Node_Str" + randomPort + healthCheckPath;
  }
  healthCheck.setTarget(healthCheckPath);
  if (healthCheck.getInterval() == null) {
    healthCheck.setInterval(30);
  }
  if (healthCheck.getHealthyThreshold() == null) {
    healthCheck.setHealthyThreshold(2);
  }
  if (healthCheck.getTimeout() == null) {
    healthCheck.setTimeout(10);
  }
  if (healthCheck.getUnhealthyThreshold() == null) {
    healthCheck.setUnhealthyThreshold(10);
  }
  elbClient.configureHealthCheck(new ConfigureHealthCheckRequest().withLoadBalancerName(appName).withHealthCheck(healthCheck));
  DescribeLoadBalancersResult elbResult=elbClient.describeLoadBalancers(new DescribeLoadBalancersRequest().withLoadBalancerNames(appName));
  LoadBalancerDescription elbDesc=elbResult.getLoadBalancerDescriptions().get(0);
  String registeredUrl=urlPrefix + "String_Node_Str" + definition.getService().getUrlSuffix();
  if (isUsingInternalSubnets) {
    dnsRegistrar.registerDns(registeredUrl,elbDesc.getDNSName(),appName,clusterMetadata.getClusterCftStackTags());
    buildLogger.addBuildLogEntry("String_Node_Str" + protocol.toLowerCase() + "String_Node_Str"+ registeredUrl);
  }
 else {
    buildLogger.addBuildLogEntry("String_Node_Str" + protocol.toLowerCase() + "String_Node_Str"+ elbDesc.getDNSName());
    buildLogger.addBuildLogEntry("String_Node_Str" + protocol.toLowerCase() + "String_Node_Str"+ registeredUrl);
  }
  buildLogger.addBuildLogEntry("String_Node_Str");
  return new LoadBalancer().withContainerName(containerName).withContainerPort(containerPort).withLoadBalancerName(appName);
}