Program: 113505
Project: 113505
Buggy source:
public static String getSysAttrValue(MRCConfig config,StorageManager sMan,OSDStatusManager osdMan,FileAccessManager faMan,String path,FileMetadata file,String keyString) throws DatabaseException, UserException, JSONException {
  if (keyString.startsWith(POLICY_ATTR_PREFIX + "String_Node_Str"))   return getPolicyValue(sMan,keyString);
  if (keyString.startsWith(VOL_ATTR_PREFIX + "String_Node_Str"))   return getVolAttrValue(sMan,keyString);
  SysAttrs key=null;
  try {
    key=SysAttrs.valueOf(keyString);
  }
 catch (  IllegalArgumentException exc) {
    throw new UserException(POSIXErrno.POSIX_ERROR_EINVAL,"String_Node_Str" + key + "String_Node_Str");
  }
  if (key != null) {
switch (key) {
case locations:
      if (file.isDirectory()) {
        return "String_Node_Str";
      }
 else {
        XLocList xLocList=file.getXLocList();
        try {
          return xLocList == null ? "String_Node_Str" : Converter.xLocListToJSON(xLocList,osdMan);
        }
 catch (        UnknownUUIDException exc) {
          throw new UserException(POSIXErrno.POSIX_ERROR_EIO,"String_Node_Str" + SysAttrs.locations.name() + "String_Node_Str"+ exc);
        }
      }
case file_id:
    return sMan.getVolumeInfo().getId() + "String_Node_Str" + file.getId();
case object_type:
  String ref=sMan.getSoftlinkTarget(file.getId());
return ref != null ? "String_Node_Str" : file.isDirectory() ? "String_Node_Str" : "String_Node_Str";
case url:
{
InetSocketAddress addr=config.getDirectoryService();
final String hostname=(config.getHostName().length() > 0) ? config.getHostName() : addr.getAddress().getCanonicalHostName();
return config.getURLScheme() + "String_Node_Str" + hostname+ "String_Node_Str"+ addr.getPort()+ "String_Node_Str"+ path;
}
case owner:
return file.getOwnerId();
case group:
return file.getOwningGroupId();
case default_sp:
if (!file.isDirectory()) return "String_Node_Str";
StripingPolicy sp=sMan.getDefaultStripingPolicy(file.getId());
if (sp == null) return "String_Node_Str";
return Converter.stripingPolicyToJSONString(sp);
case ac_policy_id:
return file.getId() == 1 ? sMan.getVolumeInfo().getAcPolicyId() + "String_Node_Str" : "String_Node_Str";
case osel_policy:
return file.getId() == 1 ? Converter.shortArrayToString(sMan.getVolumeInfo().getOsdPolicy()) : "String_Node_Str";
case rsel_policy:
return file.getId() == 1 ? Converter.shortArrayToString(sMan.getVolumeInfo().getReplicaPolicy()) : "String_Node_Str";
case read_only:
if (file.isDirectory()) return "String_Node_Str";
return String.valueOf(file.isReadOnly());
case usable_osds:
{
if (file.getId() != 1) return "String_Node_Str";
try {
ServiceSet.Builder srvs=osdMan.getUsableOSDs(sMan.getVolumeInfo().getId());
Map<String,String> osds=new HashMap<String,String>();
for (Service srv : srvs.getServicesList()) {
ServiceUUID uuid=new ServiceUUID(srv.getUuid());
InetAddress ia=uuid.getMappings()[0].resolvedAddr.getAddress();
osds.put(uuid.toString(),ia.getCanonicalHostName());
}
return JSONParser.writeJSON(osds);
}
 catch (UnknownUUIDException exc) {
throw new UserException(POSIXErrno.POSIX_ERROR_EIO,"String_Node_Str" + SysAttrs.usable_osds.name() + "String_Node_Str"+ exc);
}
}
case free_space:
return file.getId() == 1 ? String.valueOf(osdMan.getFreeSpace(sMan.getVolumeInfo().getId())) : "String_Node_Str";
case used_space:
return file.getId() == 1 ? String.valueOf(sMan.getVolumeInfo().getVolumeSize()) : "String_Node_Str";
case num_files:
return file.getId() == 1 ? String.valueOf(sMan.getVolumeInfo().getNumFiles()) : "String_Node_Str";
case num_dirs:
return file.getId() == 1 ? String.valueOf(sMan.getVolumeInfo().getNumDirs()) : "String_Node_Str";
case snapshots:
{
if (file.getId() != 1 || sMan.getVolumeInfo().isSnapVolume()) return "String_Node_Str";
StringBuilder sb=new StringBuilder();
String[] snaps=sMan.getAllSnapshots();
Arrays.sort(snaps);
for (String snap : snaps) {
if (snap.equals("String_Node_Str")) continue;
sb.append(snap);
sb.append("String_Node_Str");
}
return sb.toString();
}
case snapshots_enabled:
return file.getId() == 1 && !sMan.getVolumeInfo().isSnapVolume() ? String.valueOf(sMan.getVolumeInfo().isSnapshotsEnabled()) : "String_Node_Str";
case snapshot_time:
return file.getId() == 1 && sMan.getVolumeInfo().isSnapVolume() ? Long.toString(sMan.getVolumeInfo().getCreationTime()) : "String_Node_Str";
case acl:
Map<String,Object> acl;
try {
acl=faMan.getACLEntries(sMan,file);
}
 catch (MRCException e) {
Logging.logError(Logging.LEVEL_ERROR,null,e);
throw new UserException(POSIXErrno.POSIX_ERROR_EINVAL);
}
if (acl != null) {
StringBuilder sb=new StringBuilder();
int i=0;
for (Entry<String,Object> entry : acl.entrySet()) {
sb.append(entry.getKey());
sb.append("String_Node_Str");
sb.append(entry.getValue());
if (i < acl.size() - 1) sb.append("String_Node_Str");
i++;
}
return sb.toString();
}
case default_rp:
if (!file.isDirectory()) return "String_Node_Str";
ReplicationPolicy rp=sMan.getDefaultReplicationPolicy(file.getId());
if (rp == null) return "String_Node_Str";
return Converter.replicationPolicyToJSONString(rp);
}
}
return "String_Node_Str";
}

Fixed version (ground truth):
public static String getSysAttrValue(MRCConfig config,StorageManager sMan,OSDStatusManager osdMan,FileAccessManager faMan,String path,FileMetadata file,String keyString) throws DatabaseException, UserException, JSONException {
  if (keyString.startsWith(POLICY_ATTR_PREFIX + "String_Node_Str"))   return getPolicyValue(sMan,keyString);
  if (keyString.startsWith(VOL_ATTR_PREFIX + "String_Node_Str"))   return getVolAttrValue(sMan,keyString);
  SysAttrs key=null;
  try {
    key=SysAttrs.valueOf(keyString);
  }
 catch (  IllegalArgumentException exc) {
    throw new UserException(POSIXErrno.POSIX_ERROR_EINVAL,"String_Node_Str" + keyString + "String_Node_Str");
  }
  if (key != null) {
switch (key) {
case locations:
      if (file.isDirectory()) {
        return "String_Node_Str";
      }
 else {
        XLocList xLocList=file.getXLocList();
        try {
          return xLocList == null ? "String_Node_Str" : Converter.xLocListToJSON(xLocList,osdMan);
        }
 catch (        UnknownUUIDException exc) {
          throw new UserException(POSIXErrno.POSIX_ERROR_EIO,"String_Node_Str" + SysAttrs.locations.name() + "String_Node_Str"+ exc);
        }
      }
case file_id:
    return sMan.getVolumeInfo().getId() + "String_Node_Str" + file.getId();
case object_type:
  String ref=sMan.getSoftlinkTarget(file.getId());
return ref != null ? "String_Node_Str" : file.isDirectory() ? "String_Node_Str" : "String_Node_Str";
case url:
{
InetSocketAddress addr=config.getDirectoryService();
final String hostname=(config.getHostName().length() > 0) ? config.getHostName() : addr.getAddress().getCanonicalHostName();
return config.getURLScheme() + "String_Node_Str" + hostname+ "String_Node_Str"+ addr.getPort()+ "String_Node_Str"+ path;
}
case owner:
return file.getOwnerId();
case group:
return file.getOwningGroupId();
case default_sp:
if (!file.isDirectory()) return "String_Node_Str";
StripingPolicy sp=sMan.getDefaultStripingPolicy(file.getId());
if (sp == null) return "String_Node_Str";
return Converter.stripingPolicyToJSONString(sp);
case ac_policy_id:
return file.getId() == 1 ? sMan.getVolumeInfo().getAcPolicyId() + "String_Node_Str" : "String_Node_Str";
case osel_policy:
return file.getId() == 1 ? Converter.shortArrayToString(sMan.getVolumeInfo().getOsdPolicy()) : "String_Node_Str";
case rsel_policy:
return file.getId() == 1 ? Converter.shortArrayToString(sMan.getVolumeInfo().getReplicaPolicy()) : "String_Node_Str";
case read_only:
if (file.isDirectory()) return "String_Node_Str";
return String.valueOf(file.isReadOnly());
case usable_osds:
{
if (file.getId() != 1) return "String_Node_Str";
try {
ServiceSet.Builder srvs=osdMan.getUsableOSDs(sMan.getVolumeInfo().getId());
Map<String,String> osds=new HashMap<String,String>();
for (Service srv : srvs.getServicesList()) {
ServiceUUID uuid=new ServiceUUID(srv.getUuid());
InetAddress ia=uuid.getMappings()[0].resolvedAddr.getAddress();
osds.put(uuid.toString(),ia.getCanonicalHostName());
}
return JSONParser.writeJSON(osds);
}
 catch (UnknownUUIDException exc) {
throw new UserException(POSIXErrno.POSIX_ERROR_EIO,"String_Node_Str" + SysAttrs.usable_osds.name() + "String_Node_Str"+ exc);
}
}
case free_space:
return file.getId() == 1 ? String.valueOf(osdMan.getFreeSpace(sMan.getVolumeInfo().getId())) : "String_Node_Str";
case used_space:
return file.getId() == 1 ? String.valueOf(sMan.getVolumeInfo().getVolumeSize()) : "String_Node_Str";
case num_files:
return file.getId() == 1 ? String.valueOf(sMan.getVolumeInfo().getNumFiles()) : "String_Node_Str";
case num_dirs:
return file.getId() == 1 ? String.valueOf(sMan.getVolumeInfo().getNumDirs()) : "String_Node_Str";
case snapshots:
{
if (file.getId() != 1 || sMan.getVolumeInfo().isSnapVolume()) return "String_Node_Str";
StringBuilder sb=new StringBuilder();
String[] snaps=sMan.getAllSnapshots();
Arrays.sort(snaps);
for (String snap : snaps) {
if (snap.equals("String_Node_Str")) continue;
sb.append(snap);
sb.append("String_Node_Str");
}
return sb.toString();
}
case snapshots_enabled:
return file.getId() == 1 && !sMan.getVolumeInfo().isSnapVolume() ? String.valueOf(sMan.getVolumeInfo().isSnapshotsEnabled()) : "String_Node_Str";
case snapshot_time:
return file.getId() == 1 && sMan.getVolumeInfo().isSnapVolume() ? Long.toString(sMan.getVolumeInfo().getCreationTime()) : "String_Node_Str";
case acl:
Map<String,Object> acl;
try {
acl=faMan.getACLEntries(sMan,file);
}
 catch (MRCException e) {
Logging.logError(Logging.LEVEL_ERROR,null,e);
throw new UserException(POSIXErrno.POSIX_ERROR_EINVAL);
}
if (acl != null) {
StringBuilder sb=new StringBuilder();
int i=0;
for (Entry<String,Object> entry : acl.entrySet()) {
sb.append(entry.getKey());
sb.append("String_Node_Str");
sb.append(entry.getValue());
if (i < acl.size() - 1) sb.append("String_Node_Str");
i++;
}
return sb.toString();
}
case default_rp:
if (!file.isDirectory()) return "String_Node_Str";
ReplicationPolicy rp=sMan.getDefaultReplicationPolicy(file.getId());
if (rp == null) return "String_Node_Str";
return Converter.replicationPolicyToJSONString(rp);
}
}
return "String_Node_Str";
}