Program: 89841
Project: 89841
Buggy source:
@DB public void shutdownNetwork(long networkId){
  Transaction txn=Transaction.currentTxn();
  txn.start();
  NetworkVO network=_networksDao.lockRow(networkId,true);
  if (network == null) {
    s_logger.debug("String_Node_Str" + networkId);
    return;
  }
  if (network.getState() != Network.State.Implemented && network.getState() != Network.State.Destroying) {
    s_logger.debug("String_Node_Str" + network);
    return;
  }
  network.setState(Network.State.Destroying);
  _networksDao.update(network.getId(),network);
  txn.commit();
  boolean success=true;
  for (  NetworkElement element : _networkElements) {
    try {
      if (s_logger.isDebugEnabled()) {
        s_logger.debug("String_Node_Str" + element);
      }
      element.shutdown(network,null);
    }
 catch (    ResourceUnavailableException e) {
      s_logger.warn("String_Node_Str" + element.getName(),e);
      success=false;
    }
catch (    ConcurrentOperationException e) {
      s_logger.warn("String_Node_Str" + element.getName(),e);
      success=false;
    }
catch (    Exception e) {
      s_logger.warn("String_Node_Str" + element.getName(),e);
      success=false;
    }
  }
  txn.start();
  if (success) {
    if (s_logger.isDebugEnabled()) {
    }
    NetworkGuru guru=_networkGurus.get(network.getGuruName());
    guru.destroy(network,_networkOfferingDao.findById(network.getNetworkOfferingId()));
    network.setState(Network.State.Allocated);
    _networksDao.update(network.getId(),network);
    _networksDao.clearCheckForGc(networkId);
  }
 else {
    network.setState(Network.State.Implemented);
    _networksDao.update(network.getId(),network);
  }
  txn.commit();
}

Fixed version (ground truth):
@DB public void shutdownNetwork(long networkId){
  Transaction txn=Transaction.currentTxn();
  txn.start();
  NetworkVO network=_networksDao.lockRow(networkId,true);
  if (network == null) {
    s_logger.debug("String_Node_Str" + networkId);
    return;
  }
  if (network.getState() != Network.State.Implemented && network.getState() != Network.State.Destroying) {
    s_logger.debug("String_Node_Str" + network);
    return;
  }
  network.setState(Network.State.Destroying);
  _networksDao.update(network.getId(),network);
  txn.commit();
  boolean success=true;
  for (  NetworkElement element : _networkElements) {
    try {
      if (s_logger.isDebugEnabled()) {
        s_logger.debug("String_Node_Str" + element);
      }
      element.shutdown(network,null);
    }
 catch (    ResourceUnavailableException e) {
      s_logger.warn("String_Node_Str" + element.getName(),e);
      success=false;
    }
catch (    ConcurrentOperationException e) {
      s_logger.warn("String_Node_Str" + element.getName(),e);
      success=false;
    }
catch (    Exception e) {
      s_logger.warn("String_Node_Str" + element.getName(),e);
      success=false;
    }
  }
  txn.start();
  if (success) {
    if (s_logger.isDebugEnabled()) {
      s_logger.debug("String_Node_Str" + networkId + "String_Node_Str");
    }
    NetworkGuru guru=_networkGurus.get(network.getGuruName());
    guru.destroy(network,_networkOfferingDao.findById(network.getNetworkOfferingId()));
    network.setState(Network.State.Allocated);
    _networksDao.update(network.getId(),network);
    _networksDao.clearCheckForGc(networkId);
  }
 else {
    network.setState(Network.State.Implemented);
    _networksDao.update(network.getId(),network);
  }
  txn.commit();
}