Program: 113842
Project: 113842
Buggy source:
/** 
 * Creates a new X-Locations list
 * @param xLocList an existing X-Locations list containing a version number (may be <tt>null</tt>)
 * @param sMan the Storage Manager responsible for the file
 * @param osdMan the OSD Status Manager that periodically reports a list of usable OSDs
 * @param res the path resolver the ID of the parent directory
 * @param volume information about the volume of the file
 * @return an X-Locations list
 * @throws UserException
 * @throws BackendException
 * @throws BrainException
 */
public static XLocList createXLocList(XLocList xLocList,StorageManager sMan,OSDStatusManager osdMan,String path,long fileId,long parentDirId,VolumeInfo volume,InetSocketAddress clientAddress) throws DatabaseException, MRCException {
  assert(xLocList == null || xLocList.getReplicaCount() == 0);
  StripingPolicy stripingPolicy=sMan.getDefaultStripingPolicy(fileId);
  if (stripingPolicy == null)   stripingPolicy=sMan.getDefaultStripingPolicy(parentDirId);
  if (stripingPolicy == null)   stripingPolicy=sMan.getDefaultStripingPolicy(1);
  if (stripingPolicy == null)   throw new MRCException("String_Node_Str" + path + "String_Node_Str");
  Map<String,Map<String,Object>> osdMaps=(Map<String,Map<String,Object>>)osdMan.getUsableOSDs(volume.getId());
  if (osdMaps == null || osdMaps.size() == 0)   throw new MRCException("String_Node_Str" + path + "String_Node_Str");
  int width=Math.min((int)stripingPolicy.getWidth(),osdMaps.size());
  stripingPolicy=sMan.createStripingPolicy(stripingPolicy.getPattern(),stripingPolicy.getStripeSize(),width);
  String[] osds=osdMan.getOSDSelectionPolicy(volume.getOsdPolicyId()).getOSDsForNewFile(osdMaps,clientAddress.getAddress(),width,volume.getOsdPolicyArgs());
  XLoc[] replicas=new XLoc[]{sMan.createXLoc(stripingPolicy,osds)};
  xLocList=sMan.createXLocList(replicas,xLocList == null ? 1 : (xLocList.getVersion() + 1));
  return xLocList;
}

Fixed version (ground truth):
/** 
 * Creates a new X-Locations list
 * @param xLocList an existing X-Locations list containing a version number (may be <tt>null</tt>)
 * @param sMan the Storage Manager responsible for the file
 * @param osdMan the OSD Status Manager that periodically reports a list of usable OSDs
 * @param res the path resolver the ID of the parent directory
 * @param volume information about the volume of the file
 * @return an X-Locations list
 * @throws UserException
 * @throws BackendException
 * @throws BrainException
 */
public static XLocList createXLocList(StripingPolicy stripingPolicy,XLocList xLocList,StorageManager sMan,OSDStatusManager osdMan,String path,long fileId,long parentDirId,VolumeInfo volume,InetSocketAddress clientAddress) throws DatabaseException, MRCException {
  assert(xLocList == null || xLocList.getReplicaCount() == 0);
  if (stripingPolicy == null)   stripingPolicy=sMan.getDefaultStripingPolicy(parentDirId);
  if (stripingPolicy == null)   stripingPolicy=sMan.getDefaultStripingPolicy(1);
  if (stripingPolicy == null)   throw new MRCException("String_Node_Str" + path + "String_Node_Str");
  Map<String,Map<String,Object>> osdMaps=(Map<String,Map<String,Object>>)osdMan.getUsableOSDs(volume.getId());
  if (osdMaps == null || osdMaps.size() == 0)   throw new MRCException("String_Node_Str" + path + "String_Node_Str");
  int width=Math.min((int)stripingPolicy.getWidth(),osdMaps.size());
  stripingPolicy=sMan.createStripingPolicy(stripingPolicy.getPattern(),stripingPolicy.getStripeSize(),width);
  String[] osds=osdMan.getOSDSelectionPolicy(volume.getOsdPolicyId()).getOSDsForNewFile(osdMaps,clientAddress.getAddress(),width,volume.getOsdPolicyArgs());
  XLoc[] replicas=new XLoc[]{sMan.createXLoc(stripingPolicy,osds)};
  xLocList=sMan.createXLocList(replicas,xLocList == null ? 1 : (xLocList.getVersion() + 1));
  return xLocList;
}