Program: 14357
Project: 14357
Buggy source:
public DescribeInstanceHealthResponseType describeInstanceHealth(DescribeInstanceHealthType request) throws EucalyptusCloudException {
  DescribeInstanceHealthResponseType reply=request.getReply();
  final Context ctx=Contexts.lookup();
  final UserFullName ownerFullName=ctx.getUserFullName();
  final String lbName=request.getLoadBalancerName();
  Instances instances=request.getInstances();
  LoadBalancer lb=null;
  try {
    lb=LoadBalancers.getLoadbalancer(ownerFullName,lbName);
  }
 catch (  NoSuchElementException ex) {
    throw new AccessPointNotFoundException();
  }
catch (  Exception ex) {
    throw new LoadBalancingException("String_Node_Str");
  }
  List<LoadBalancerBackendInstance> instancesFound=Lists.newArrayList();
  if (instances != null && instances.getMember() != null && instances.getMember().size() > 0) {
    final EntityTransaction db=Entities.get(LoadBalancerBackendInstance.class);
    for (    Instance inst : instances.getMember()) {
      String instId=inst.getInstanceId();
      try {
        LoadBalancerBackendInstance found=Entities.uniqueResult(LoadBalancerBackendInstance.named(ownerFullName,instId));
        instancesFound.add(found);
      }
 catch (      NoSuchElementException ex) {
        ;
      }
catch (      Exception ex) {
        LOG.error("String_Node_Str",ex);
      }
    }
    db.commit();
  }
 else {
    final EntityTransaction db=Entities.get(LoadBalancerBackendInstance.class);
    try {
      instancesFound=Entities.query(LoadBalancerBackendInstance.named(ownerFullName));
      db.commit();
    }
 catch (    NoSuchElementException ex) {
      db.rollback();
    }
catch (    Exception ex) {
      LOG.error("String_Node_Str",ex);
      db.rollback();
    }
  }
  final ArrayList<InstanceState> stateList=Lists.newArrayList();
  for (  final LoadBalancerBackendInstance instance : instancesFound) {
    InstanceState state=new InstanceState();
    state.setInstanceId(instance.getDisplayName());
    state.setState(instance.getState().name());
    if (instance.getState().equals(LoadBalancerBackendInstance.STATE.OutOfService) && instance.getReasonCode() != null)     state.setReasonCode(instance.getReasonCode());
    stateList.add(state);
  }
  final InstanceStates states=new InstanceStates();
  states.setMember(stateList);
  final DescribeInstanceHealthResult result=new DescribeInstanceHealthResult();
  result.setInstanceStates(states);
  reply.setDescribeInstanceHealthResult(result);
  return reply;
}

Fixed version (ground truth):
public DescribeInstanceHealthResponseType describeInstanceHealth(DescribeInstanceHealthType request) throws EucalyptusCloudException {
  DescribeInstanceHealthResponseType reply=request.getReply();
  final Context ctx=Contexts.lookup();
  final UserFullName ownerFullName=ctx.getUserFullName();
  final String lbName=request.getLoadBalancerName();
  Instances instances=request.getInstances();
  LoadBalancer lb=null;
  try {
    lb=LoadBalancers.getLoadbalancer(ownerFullName,lbName);
  }
 catch (  NoSuchElementException ex) {
    throw new AccessPointNotFoundException();
  }
catch (  Exception ex) {
    throw new LoadBalancingException("String_Node_Str");
  }
  List<LoadBalancerBackendInstance> instancesFound=Lists.newArrayList();
  if (instances != null && instances.getMember() != null && instances.getMember().size() > 0) {
    final EntityTransaction db=Entities.get(LoadBalancerBackendInstance.class);
    for (    Instance inst : instances.getMember()) {
      String instId=inst.getInstanceId();
      try {
        LoadBalancerBackendInstance found=Entities.uniqueResult(LoadBalancerBackendInstance.named(ownerFullName,lb,instId));
        instancesFound.add(found);
      }
 catch (      NoSuchElementException ex) {
        ;
      }
catch (      Exception ex) {
        LOG.error("String_Node_Str",ex);
      }
    }
    db.commit();
  }
 else {
    final EntityTransaction db=Entities.get(LoadBalancerBackendInstance.class);
    try {
      instancesFound=Entities.query(LoadBalancerBackendInstance.named(ownerFullName,lb));
      db.commit();
    }
 catch (    NoSuchElementException ex) {
      db.rollback();
    }
catch (    Exception ex) {
      LOG.error("String_Node_Str",ex);
      db.rollback();
    }
  }
  final ArrayList<InstanceState> stateList=Lists.newArrayList();
  for (  final LoadBalancerBackendInstance instance : instancesFound) {
    InstanceState state=new InstanceState();
    state.setInstanceId(instance.getDisplayName());
    state.setState(instance.getState().name());
    if (instance.getState().equals(LoadBalancerBackendInstance.STATE.OutOfService) && instance.getReasonCode() != null)     state.setReasonCode(instance.getReasonCode());
    stateList.add(state);
  }
  final InstanceStates states=new InstanceStates();
  states.setMember(stateList);
  final DescribeInstanceHealthResult result=new DescribeInstanceHealthResult();
  result.setInstanceStates(states);
  reply.setDescribeInstanceHealthResult(result);
  return reply;
}