nus-yam/ex-repair huggingface dataset:
Program: 7458
Project: 7458
Buggy source:
/** 
 * Binds the specified object value to this field.
 * @param value      the value to bind
 * @param params     the array of SQL parameters
 * @return the new SQL text for the field
 */
public String bind(Object value,ArrayList params){
  if (value == null) {
    return bindNull();
  }
 else   if (value instanceof String && ((String)value).length() < 100) {
    return cond(column,operator,literal((String)value));
  }
 else   if (value instanceof Array) {
    return bindData((Array)value,params);
  }
 else   if (value instanceof Date) {
    params.add(new java.sql.Timestamp(((Date)value).getTime()));
    return cond(column,operator,"String_Node_Str");
  }
 else {
    params.add(value);
    return cond(column,operator,"String_Node_Str");
  }
}

Fixed version (ground truth):
/** 
 * Binds the specified object value to this field.
 * @param value      the value to bind
 * @param params     the array of SQL parameters
 * @return the new SQL text for the field
 */
public String bind(Object value,ArrayList params){
  if (value == null) {
    return bindNull();
  }
 else   if (value instanceof Array) {
    return bindData((Array)value,params);
  }
 else   if (value instanceof Date) {
    params.add(new java.sql.Timestamp(((Date)value).getTime()));
    return cond(column,operator,"String_Node_Str");
  }
 else {
    params.add(value);
    return cond(column,operator,"String_Node_Str");
  }
}
Program: 7459
Project: 7459
Buggy source:
/** 
 * Returns the host name in the request.
 * @return the host name
 */
public String getHost(){
  if (requestHost == null) {
    String str1=request.getHeader("String_Node_Str");
    String str2=request.getHeader("String_Node_Str");
    str1=RegexUtil.firstMatch(RE_HEADER_VALUE,str1);
    str2=RegexUtil.firstMatch(RE_HEADER_VALUE,str2);
    str2=StringUtils.substringBefore(str2,"String_Node_Str");
    String str3=StringUtils.defaultIfEmpty(str1,str2);
    String str4=request.getServerName();
    requestHost=StringUtils.defaultIfEmpty(str3,str4);
  }
  return requestHost;
}

Fixed version (ground truth):
/** 
 * Returns the host name in the request.
 * @return the host name
 */
public String getHost(){
  if (requestHost == null) {
    String str1=request.getHeader("String_Node_Str");
    String str2=request.getHeader("String_Node_Str");
    str1=RegexUtil.firstMatch(RE_HEADER_VALUE,str1);
    str2=RegexUtil.firstMatch(RE_HEADER_VALUE,str2);
    str2=StringUtils.substringBefore(str2,"String_Node_Str");
    String str3=StringUtils.defaultIfEmpty(str1,str2);
    String str4;
    try {
      str4=request.getServerName();
    }
 catch (    NumberFormatException ignore) {
      str4="String_Node_Str";
    }
    requestHost=StringUtils.defaultIfEmpty(str3,str4);
  }
  return requestHost;
}
Program: 7460
Project: 7460
Buggy source:
/** 
 * Unmounts a storage from the specified path. The path must have previously been used to mount a storage, which will also be destroyed by this operation.
 * @param path           the mount path
 * @throws StorageException if the storage couldn't be unmounted
 */
public void unmount(Path path) throws StorageException {
  Storage storage=getMountedStorage(path,true);
  String msg;
  if (storage == null) {
    msg="String_Node_Str" + path;
    LOG.warning(msg);
    throw new StorageException(msg);
  }
  LOG.fine("String_Node_Str" + storage);
  updateStorageCache(path,null);
  mountedStorages.remove(mountedStorages.indexOf(storage));
  updateStorageMetadata(storage,false);
  storage.destroy();
}

Fixed version (ground truth):
/** 
 * Unmounts a storage from the specified path. The path must have previously been used to mount a storage, which will also be destroyed by this operation.
 * @param path           the mount path
 * @throws StorageException if the storage couldn't be unmounted
 */
public synchronized void unmount(Path path) throws StorageException {
  Storage storage=getMountedStorage(path,true);
  String msg;
  if (storage == null) {
    msg="String_Node_Str" + path;
    LOG.warning(msg);
    throw new StorageException(msg);
  }
  LOG.fine("String_Node_Str" + storage);
  updateStorageCache(path,null);
  mountedStorages.remove(mountedStorages.indexOf(storage));
  updateStorageMetadata(storage,false);
  storage.destroy();
}
Program: 7461
Project: 7461
Buggy source:
/** 
 * Destroys all cached objects. The objects will first be passivated and thereafter queried for their status. All modified objects will be stored persistently if possible, but errors will only be logged. If the force clean flag is set, all objects in the cache will be destroyed. Otherwise only inactive objects.<p> This method is called regularly from a background job in order to destroy inactive objects.
 * @param force          the forced clean flag
 */
public void cacheClean(boolean force){
  Iterator iter=cacheStorages.values().iterator();
  while (iter.hasNext()) {
    cacheRemove((MemoryStorage)iter.next(),Path.ROOT,true,force);
  }
}

Fixed version (ground truth):
/** 
 * Destroys all cached objects. The objects will first be passivated and thereafter queried for their status. All modified objects will be stored persistently if possible, but errors will only be logged. If the force clean flag is set, all objects in the cache will be destroyed. Otherwise only inactive objects.<p> This method is called regularly from a background job in order to destroy inactive objects.
 * @param force          the forced clean flag
 */
public synchronized void cacheClean(boolean force){
  Iterator iter=cacheStorages.values().iterator();
  while (iter.hasNext()) {
    cacheRemove((MemoryStorage)iter.next(),Path.ROOT,true,force);
  }
}
Program: 7462
Project: 7462
Buggy source:
/** 
 * Mounts a storage to a unique path. The path may not collide with a previously mounted storage, such that it would hide or be hidden by the other storage. Overlapping parent indices will be merged automatically. In addition to adding the storage to the specified path, it's contents may also be overlaid directly on the root path.
 * @param storage        the storage to mount
 * @param path           the mount path
 * @param readWrite      the read write flag
 * @param overlay        the root overlay path
 * @param prio           the root overlay search priority (higher numbersare searched before lower numbers)
 * @throws StorageException if the storage couldn't be mounted
 */
public void mount(Storage storage,Path path,boolean readWrite,Path overlay,int prio) throws StorageException {
  String msg;
  if (!path.isIndex()) {
    msg="String_Node_Str" + path;
    LOG.warning(msg);
    throw new StorageException(msg);
  }
 else   if (!path.startsWith(PATH_STORAGE)) {
    msg="String_Node_Str" + path;
    LOG.warning(msg);
    throw new StorageException(msg);
  }
 else   if (metadata.lookup(path) != null) {
    msg="String_Node_Str" + path;
    LOG.warning(msg);
    throw new StorageException(msg);
  }
  LOG.fine("String_Node_Str" + storage);
  storage.setMountInfo(path,readWrite,overlay,prio);
  updateStorageMetadata(storage,true);
  mountedStorages.add(storage);
  mountedStorages.sort();
  updateStorageCache(path,overlay);
}

Fixed version (ground truth):
/** 
 * Mounts a storage to a unique path. The path may not collide with a previously mounted storage, such that it would hide or be hidden by the other storage. Overlapping parent indices will be merged automatically. In addition to adding the storage to the specified path, it's contents may also be overlaid directly on the root path.
 * @param storage        the storage to mount
 * @param path           the mount path
 * @param readWrite      the read write flag
 * @param overlay        the root overlay path
 * @param prio           the root overlay search priority (higher numbersare searched before lower numbers)
 * @throws StorageException if the storage couldn't be mounted
 */
public synchronized void mount(Storage storage,Path path,boolean readWrite,Path overlay,int prio) throws StorageException {
  String msg;
  if (!path.isIndex()) {
    msg="String_Node_Str" + path;
    LOG.warning(msg);
    throw new StorageException(msg);
  }
 else   if (!path.startsWith(PATH_STORAGE)) {
    msg="String_Node_Str" + path;
    LOG.warning(msg);
    throw new StorageException(msg);
  }
 else   if (metadata.lookup(path) != null) {
    msg="String_Node_Str" + path;
    LOG.warning(msg);
    throw new StorageException(msg);
  }
  LOG.fine("String_Node_Str" + storage);
  storage.setMountInfo(path,readWrite,overlay,prio);
  updateStorageMetadata(storage,true);
  mountedStorages.add(storage);
  mountedStorages.sort();
  updateStorageCache(path,overlay);
}
Program: 7463
Project: 7463
Buggy source:
/** 
 * Remounts a storage for a unique path. The path or the storage are not modified, but only the mounting options.
 * @param path           the mount path
 * @param readWrite      the read write flag
 * @param overlay        the root overlay path
 * @param prio           the root overlay search priority (higher numbersare searched before lower numbers)
 * @throws StorageException if the storage couldn't be remounted
 */
public void remount(Path path,boolean readWrite,Path overlay,int prio) throws StorageException {
  Storage storage=getMountedStorage(path,true);
  if (storage == null) {
    String msg="String_Node_Str" + path;
    LOG.warning(msg);
    throw new StorageException(msg);
  }
  LOG.fine("String_Node_Str" + storage);
  updateStorageMetadata(storage,false);
  storage.setMountInfo(storage.path(),readWrite,overlay,prio);
  updateStorageMetadata(storage,true);
  mountedStorages.sort();
  updateStorageCache(path,overlay);
}

Fixed version (ground truth):
/** 
 * Remounts a storage for a unique path. The path or the storage are not modified, but only the mounting options.
 * @param path           the mount path
 * @param readWrite      the read write flag
 * @param overlay        the root overlay path
 * @param prio           the root overlay search priority (higher numbersare searched before lower numbers)
 * @throws StorageException if the storage couldn't be remounted
 */
public synchronized void remount(Path path,boolean readWrite,Path overlay,int prio) throws StorageException {
  Storage storage=getMountedStorage(path,true);
  if (storage == null) {
    String msg="String_Node_Str" + path;
    LOG.warning(msg);
    throw new StorageException(msg);
  }
  LOG.fine("String_Node_Str" + storage);
  updateStorageMetadata(storage,false);
  storage.setMountInfo(storage.path(),readWrite,overlay,prio);
  updateStorageMetadata(storage,true);
  mountedStorages.sort();
  updateStorageCache(path,overlay);
}
Program: 7464
Project: 7464
Buggy source:
/** 
 * Unmounts and destroys all mounted storages.
 */
public void unmountAll(){
  Storage storage;
  String msg;
  while (mountedStorages.size() > 0) {
    storage=(Storage)mountedStorages.get(mountedStorages.size() - 1);
    try {
      unmount(storage.path());
    }
 catch (    Exception e) {
      msg="String_Node_Str" + storage.path();
      LOG.log(Level.WARNING,msg,e);
    }
  }
}

Fixed version (ground truth):
/** 
 * Unmounts and destroys all mounted storages.
 */
public synchronized void unmountAll(){
  Storage storage;
  String msg;
  while (mountedStorages.size() > 0) {
    storage=(Storage)mountedStorages.get(mountedStorages.size() - 1);
    try {
      unmount(storage.path());
    }
 catch (    Exception e) {
      msg="String_Node_Str" + storage.path();
      LOG.log(Level.WARNING,msg,e);
    }
  }
}
Program: 7465
Project: 7465
Buggy source:
/** 
 * Destroys this storage. Note that the objects in the storage will NOT be destroyed by this method.
 */
public void destroy(){
  objects.clear();
  meta.clear();
  objects=null;
  meta=null;
}

Fixed version (ground truth):
/** 
 * Destroys this storage. Note that the objects in the storage will NOT be destroyed by this method.
 */
public synchronized void destroy(){
  objects.clear();
  meta.clear();
  objects=null;
  meta=null;
}
Program: 7466
Project: 7466
Buggy source:
/** 
 * Stores an object at the specified location. The path must locate a particular object or file, since direct manipulation of indices is not supported. Any previous data at the specified path will be overwritten or removed.
 * @param path           the storage location
 * @param data           the data to store
 * @throws StorageException if the data couldn't be written
 */
public void store(Path path,Object data) throws StorageException {
  String msg;
  if (path.isIndex()) {
    msg="String_Node_Str" + path;
    LOG.warning(msg);
    throw new StorageException(msg);
  }
 else   if (data == null) {
    msg="String_Node_Str" + path;
    LOG.warning(msg);
    throw new StorageException(msg);
  }
 else   if (!isReadWrite()) {
    msg="String_Node_Str" + path();
    LOG.warning(msg);
    throw new StorageException(msg);
  }
 else   if (!isStorable(data)) {
    msg="String_Node_Str" + path() + "String_Node_Str"+ data.getClass().getName();
    LOG.warning(msg);
    throw new StorageException(msg);
  }
  if (objects.containsKey(path)) {
    remove(path);
  }
  objects.put(path,data);
  meta.put(path,new Metadata(data.getClass(),path,path(),-1));
  indexInsert(path);
}

Fixed version (ground truth):
/** 
 * Stores an object at the specified location. The path must locate a particular object or file, since direct manipulation of indices is not supported. Any previous data at the specified path will be overwritten or removed.
 * @param path           the storage location
 * @param data           the data to store
 * @throws StorageException if the data couldn't be written
 */
public synchronized void store(Path path,Object data) throws StorageException {
  String msg;
  if (path.isIndex()) {
    msg="String_Node_Str" + path;
    LOG.warning(msg);
    throw new StorageException(msg);
  }
 else   if (data == null) {
    msg="String_Node_Str" + path;
    LOG.warning(msg);
    throw new StorageException(msg);
  }
 else   if (!isReadWrite()) {
    msg="String_Node_Str" + path();
    LOG.warning(msg);
    throw new StorageException(msg);
  }
 else   if (!isStorable(data)) {
    msg="String_Node_Str" + path() + "String_Node_Str"+ data.getClass().getName();
    LOG.warning(msg);
    throw new StorageException(msg);
  }
  if (objects.containsKey(path)) {
    remove(path);
  }
  objects.put(path,data);
  meta.put(path,new Metadata(data.getClass(),path,path(),-1));
  indexInsert(path);
}
Program: 7467
Project: 7467
Buggy source:
/** 
 * Destroys all cached objects. The objects will first be passivated and thereafter queried for their status. All modified objects will be stored persistently if possible, but errors will only be logged. If the force clean flag is set, all objects in the cache will be destroyed. Otherwise only inactive objects.<p> This method is called regularly from a background job in order to destroy inactive objects.
 * @param force          the forced clean flag
 */
public synchronized void cacheClean(boolean force){
  Iterator iter=cacheStorages.values().iterator();
  while (iter.hasNext()) {
    cacheRemove((MemoryStorage)iter.next(),Path.ROOT,true,force);
  }
}

Fixed version (ground truth):
/** 
 * Destroys all cached objects. The objects will first be passivated and thereafter queried for their status. All modified objects will be stored persistently if possible, but errors will only be logged. If the force clean flag is set, all objects in the cache will be destroyed. Otherwise only inactive objects.<p> This method is called regularly from a background job in order to destroy inactive objects.
 * @param force          the forced clean flag
 */
public void cacheClean(boolean force){
  Iterator iter=cacheStorages.values().iterator();
  while (iter.hasNext()) {
    cacheRemove((MemoryStorage)iter.next(),Path.ROOT,true,force);
  }
}
Program: 7468
Project: 7468
Buggy source:
/** 
 * Checks if the request input matches one of the specified MIME types. The input MIME type is read from the 'Content-Type' HTTP header, not from the data stream itself.
 * @param request        the request to analyze
 * @param mimes          the MIME types to check for
 * @return true if one of the MIME types match, orfalse otherwise
 */
public static boolean isInputMatch(Request request,String[] mimes){
  return isMatch(request.getContentType(),mimes);
}

Fixed version (ground truth):
/** 
 * Checks if the request input matches one of the specified MIME types. The input MIME type is read from the 'Content-Type' HTTP header, not from the data stream itself.
 * @param request        the request to analyze
 * @param mimes          the MIME types to check for
 * @return true if one of the MIME types match, orfalse otherwise
 */
public static boolean isInputMatch(Request request,String[] mimes){
  if (request.getContentType() == null) {
    return false;
  }
 else {
    return isMatch(request.getContentType(),mimes);
  }
}
Program: 7469
Project: 7469
Buggy source:
/** 
 * Converts a string into an approximate value type. The strings "true" and "false" will be converted into boolean values. Any numeric strings will be converted into an integer. All remaining string values will be returned as-is.
 * @param value          the string to convert
 * @return the converted value
 */
private static Object toValue(String value){
  if (value.equals("String_Node_Str") || value.equals("String_Node_Str")) {
    return Boolean.valueOf(value);
  }
 else   if (StringUtils.isNumeric(value)) {
    return Integer.valueOf(value);
  }
 else   if (value.startsWith("String_Node_Str") && StringUtils.isNumeric(value.substring(1))) {
    return new Date(Long.parseLong(value.substring(1)));
  }
 else {
    return value;
  }
}

Fixed version (ground truth):
/** 
 * Converts a string into an approximate value type. The strings "true" and "false" will be converted into boolean values. Any numeric strings will be converted into an integer. All remaining string values will be returned as-is.
 * @param value          the string to convert
 * @return the converted value
 */
private static Object toValue(String value){
  if (value.equals("String_Node_Str") || value.equals("String_Node_Str")) {
    return Boolean.valueOf(value);
  }
 else   if (value.length() > 0 && StringUtils.isNumeric(value)) {
    return Integer.valueOf(value);
  }
 else   if (value.startsWith("String_Node_Str") && StringUtils.isNumeric(value.substring(1))) {
    return new Date(Long.parseLong(value.substring(1)));
  }
 else {
    return value;
  }
}
Program: 7470
Project: 7470
Buggy source:
/** 
 * Converts a string to an array index. The string must only consist of ASCII numbers for the conversion to succeed.
 * @param str            the string to convert
 * @return the array index, or-1 if the conversion failed
 */
private static int toIndex(String str){
  int index=-1;
  if (StringUtils.isNumeric(str)) {
    try {
      index=Integer.parseInt(str);
    }
 catch (    NumberFormatException ignore) {
    }
  }
  return str.equals(String.valueOf(index)) ? index : -1;
}

Fixed version (ground truth):
/** 
 * Converts a string to an array index. The string must only consist of ASCII numbers for the conversion to succeed.
 * @param str            the string to convert
 * @return the array index, or-1 if the conversion failed
 */
private static int toIndex(String str){
  int index=-1;
  if (str.length() > 0 && StringUtils.isNumeric(str)) {
    try {
      index=Integer.parseInt(str);
    }
 catch (    NumberFormatException ignore) {
    }
  }
  return str.equals(String.valueOf(index)) ? index : -1;
}
Program: 7471
Project: 7471
Buggy source:
/** 
 * Replaces any parameters with the corresponding argument value from the bindings.
 * @param data           the data string to process
 * @param bindings       the bindings to use
 * @return the processed data string
 * @throws ProcedureException if some parameter couldn't be found
 */
private static String replaceArguments(String data,Bindings bindings) throws ProcedureException {
  String[] names=bindings.getNames();
  for (int i=0; i < names.length; i++) {
    if (bindings.getType(names[i]) == Bindings.ARGUMENT) {
      Object value=bindings.getValue(names[i],null);
      if (value == null) {
        value="String_Node_Str";
      }
      data=data.replaceAll("String_Node_Str" + names[i],value.toString());
    }
  }
  return data;
}

Fixed version (ground truth):
/** 
 * Replaces any parameters with the corresponding argument value from the bindings.
 * @param data           the data string to process
 * @param bindings       the bindings to use
 * @return the processed data string
 * @throws ProcedureException if some parameter couldn't be found
 */
private static String replaceArguments(String data,Bindings bindings) throws ProcedureException {
  String[] names=bindings.getNames();
  for (int i=0; i < names.length; i++) {
    if (bindings.getType(names[i]) == Bindings.ARGUMENT) {
      Object value=bindings.getValue(names[i],null);
      if (value == null) {
        value="String_Node_Str";
      }
      data=StringUtils.replace(data,"String_Node_Str" + names[i],value.toString());
    }
  }
  return data;
}
Program: 7472
Project: 7472
Buggy source:
/** 
 * Replaces any parameters with the corresponding argument value from the bindings.
 * @param data           the data string to process
 * @param bindings       the bindings to use
 * @return the processed data string
 * @throws ProcedureException if some parameter couldn't be found
 */
private static String replaceArguments(String data,Bindings bindings) throws ProcedureException {
  String[] names=bindings.getNames();
  Object value;
  for (int i=0; i < names.length; i++) {
    if (bindings.getType(names[i]) == Bindings.ARGUMENT) {
      value=bindings.getValue(names[i],null);
      if (value == null) {
        value="String_Node_Str";
      }
      data=data.replaceAll("String_Node_Str" + names[i],value.toString());
    }
  }
  return data;
}

Fixed version (ground truth):
/** 
 * Replaces any parameters with the corresponding argument value from the bindings.
 * @param data           the data string to process
 * @param bindings       the bindings to use
 * @return the processed data string
 * @throws ProcedureException if some parameter couldn't be found
 */
private static String replaceArguments(String data,Bindings bindings) throws ProcedureException {
  String[] names=bindings.getNames();
  Object value;
  for (int i=0; i < names.length; i++) {
    if (bindings.getType(names[i]) == Bindings.ARGUMENT) {
      value=bindings.getValue(names[i],null);
      if (value == null) {
        value="String_Node_Str";
      }
      data=StringUtils.replace(data,"String_Node_Str" + names[i],value.toString());
    }
  }
  return data;
}
Program: 7473
Project: 7473
Buggy source:
/** 
 * Verifies that the specified authentication token is valid for this user.
 * @param token          the authentication token
 * @return true if the token is valid, orfalse otherwise
 */
public boolean verifyAuthToken(String token){
  String[] parts=User.decodeAuthToken(token);
  long expiry=Long.parseLong(parts[1]);
  boolean isExpired=expiry < System.currentTimeMillis();
  return isEnabled() && !isExpired && createAuthToken(expiry).equals(token);
}

Fixed version (ground truth):
/** 
 * Verifies that the specified authentication token is valid for this user.
 * @param token          the authentication token
 * @return true if the token is valid, orfalse otherwise
 */
public boolean verifyAuthToken(String token){
  String[] parts=User.decodeAuthToken(token);
  long expiry=parts.length <= 1 ? 0L : Long.parseLong(parts[1]);
  boolean isExpired=expiry < System.currentTimeMillis();
  return isEnabled() && !isExpired && createAuthToken(expiry).equals(token);
}
Program: 7474
Project: 7474
Buggy source:
/** 
 * Encodes a byte array to a string with hexadecimal numbers.
 * @param data           the byte array
 * @return the hexadecimal string with the converted data
 */
public static String encodeHexString(byte[] data){
  StringBuffer hexString=new StringBuffer();
  for (int i=0; i < data.length; i++) {
    hexString.append(Character.forDigit(data[i] & 0xF0 >> 4,16));
    hexString.append(Character.forDigit(data[i] & 0x0F,16));
  }
  return hexString.toString();
}

Fixed version (ground truth):
/** 
 * Encodes a byte array to a string with hexadecimal numbers.
 * @param data           the byte array
 * @return the hexadecimal string with the converted data
 */
public static String encodeHexString(byte[] data){
  StringBuffer hexString=new StringBuffer();
  for (int i=0; i < data.length; i++) {
    hexString.append(Character.forDigit((data[i] & 0xF0) >> 4,16));
    hexString.append(Character.forDigit(data[i] & 0x0F,16));
  }
  return hexString.toString();
}
Program: 7476
Project: 7476
Buggy source:
/** 
 * Searches for a specific connection in the storage.
 * @param storage        the storage to search in
 * @param id             the connection identifier
 * @return the connection found, ornull if not found
 */
public static Connection find(Storage storage,String id){
  Object obj=storage.load(PATH.descendant(new Path(id)));
  return (obj instanceof Connection) ? (Connection)obj : null;
}

Fixed version (ground truth):
/** 
 * Searches for a specific connection in the storage.
 * @param storage        the storage to search in
 * @param id             the connection identifier
 * @return the connection found, ornull if not found
 */
public static Connection find(Storage storage,String id){
  Object obj=storage.load(new Path(PATH,id));
  return (obj instanceof Connection) ? (Connection)obj : null;
}
Program: 7477
Project: 7477
Buggy source:
/** 
 * Searches for a specific environment in the storage.
 * @param storage        the storage to search in
 * @param id             the environment identifier
 * @return the environment found, ornull if not found
 */
public static Environment find(Storage storage,String id){
  Object obj=storage.load(PATH.descendant(new Path(id)));
  return (obj instanceof Environment) ? (Environment)obj : null;
}

Fixed version (ground truth):
/** 
 * Searches for a specific environment in the storage.
 * @param storage        the storage to search in
 * @param id             the environment identifier
 * @return the environment found, ornull if not found
 */
public static Environment find(Storage storage,String id){
  Object obj=storage.load(new Path(PATH,id));
  return (obj instanceof Environment) ? (Environment)obj : null;
}
Program: 7478
Project: 7478
Buggy source:
/** 
 * Removes the specified session id from the provided storage.
 * @param storage        the storage to use
 * @param id             the session id to remove
 */
public static void remove(Storage storage,String id){
  try {
    storage.remove(PATH.child(id,false));
  }
 catch (  StorageException e) {
    LOG.log(Level.WARNING,"String_Node_Str" + id,e);
  }
}

Fixed version (ground truth):
/** 
 * Removes the specified session id from the provided storage.
 * @param storage        the storage to use
 * @param id             the session id to remove
 */
public static void remove(Storage storage,String id){
  try {
    storage.remove(new Path(PATH,id));
  }
 catch (  StorageException e) {
    LOG.log(Level.WARNING,"String_Node_Str" + id,e);
  }
}
Program: 7479
Project: 7479
Buggy source:
/** 
 * Searches for a specific session in the storage.
 * @param storage        the storage to search in
 * @param id             the session identifier
 * @return the session found, ornull if not found
 */
public static Session find(Storage storage,String id){
  Object obj=storage.load(PATH.child(id,false));
  return (obj instanceof Session) ? (Session)obj : null;
}

Fixed version (ground truth):
/** 
 * Searches for a specific session in the storage.
 * @param storage        the storage to search in
 * @param id             the session identifier
 * @return the session found, ornull if not found
 */
public static Session find(Storage storage,String id){
  Object obj=storage.load(new Path(PATH,id));
  return (obj instanceof Session) ? (Session)obj : null;
}
Program: 7480
Project: 7480
Buggy source:
/** 
 * Stores the specified session in the provided storage.
 * @param storage        the storage to use
 * @param session        the session to store
 * @throws StorageException if the session couldn't be stored
 */
public static void store(Storage storage,Session session) throws StorageException {
  storage.store(PATH.child(session.id(),false),session);
}

Fixed version (ground truth):
/** 
 * Stores the specified session in the provided storage.
 * @param storage        the storage to use
 * @param session        the session to store
 * @throws StorageException if the session couldn't be stored
 */
public static void store(Storage storage,Session session) throws StorageException {
  storage.store(session.path(),session);
}
Program: 7481
Project: 7481
Buggy source:
/** 
 * Searches for a specific type in the storage.
 * @param storage        the storage to search in
 * @param id             the type identifier
 * @return the type found, ornull if not found
 */
public static Type find(Storage storage,String id){
  Object obj=storage.load(PATH.descendant(new Path(id)));
  return (obj instanceof Type) ? (Type)obj : null;
}

Fixed version (ground truth):
/** 
 * Searches for a specific type in the storage.
 * @param storage        the storage to search in
 * @param id             the type identifier
 * @return the type found, ornull if not found
 */
public static Type find(Storage storage,String id){
  Object obj=storage.load(new Path(PATH,id));
  return (obj instanceof Type) ? (Type)obj : null;
}
Program: 7482
Project: 7482
Buggy source:
/** 
 * Stores the specified used in the provided storage.
 * @param storage        the storage to use
 * @param user           the user to store
 * @throws StorageException if the user couldn't be stored
 */
public static void store(Storage storage,User user) throws StorageException {
  storage.store(PATH.child(user.id(),false),user);
}

Fixed version (ground truth):
/** 
 * Stores the specified used in the provided storage.
 * @param storage        the storage to use
 * @param user           the user to store
 * @throws StorageException if the user couldn't be stored
 */
public static void store(Storage storage,User user) throws StorageException {
  storage.store(user.path(),user);
}
Program: 7483
Project: 7483
Buggy source:
/** 
 * Searches for a specific user in the storage.
 * @param storage        the storage to search in
 * @param id             the user identifier
 * @return the user found, ornull if not found
 */
public static User find(Storage storage,String id){
  Object obj=storage.load(PATH.descendant(new Path(id)));
  return (obj instanceof User) ? (User)obj : null;
}

Fixed version (ground truth):
/** 
 * Searches for a specific user in the storage.
 * @param storage        the storage to search in
 * @param id             the user identifier
 * @return the user found, ornull if not found
 */
public static User find(Storage storage,String id){
  Object obj=storage.load(new Path(PATH,id));
  return (obj instanceof User) ? (User)obj : null;
}
Program: 7484
Project: 7484
Buggy source:
/** 
 * Copies a storage object to a new destination.
 * @param src            the source object path
 * @param dst            the destination object path
 * @param updateOnly     the copy-only-on-newer flag
 * @return true if the data was successfully copied, orfalse otherwise
 */
public static boolean delete(Path path){
  Storage storage=ApplicationContext.getInstance().getStorage();
  try {
    storage.remove(path);
    return true;
  }
 catch (  Exception e) {
    LOG.log(Level.WARNING,"String_Node_Str" + path,e);
    return false;
  }
}

Fixed version (ground truth):
/** 
 * Deletes a storage object or path.
 * @param path           the storage path to remove
 * @return true if the data was successfully removed, orfalse otherwise
 */
public static boolean delete(Path path){
  Storage storage=ApplicationContext.getInstance().getStorage();
  try {
    storage.remove(path);
    return true;
  }
 catch (  Exception e) {
    LOG.log(Level.WARNING,"String_Node_Str" + path,e);
    return false;
  }
}
Program: 7485
Project: 7485
Buggy source:
/** 
 * Copies a storage object to a new destination.
 * @param src            the source object path
 * @param dst            the destination object path
 * @param updateOnly     the copy-only-on-newer flag
 * @return true if the data was successfully copied, orfalse otherwise
 */
public static boolean store(Path path,Object data){
  Storage storage=ApplicationContext.getInstance().getStorage();
  try {
    storage.store(path,data);
    return true;
  }
 catch (  Exception e) {
    LOG.log(Level.WARNING,"String_Node_Str" + path,e);
    return false;
  }
}

Fixed version (ground truth):
/** 
 * Writes a data object to the storage.
 * @param path           the storage path
 * @param data           the data object
 * @return true if the data was successfully written, orfalse otherwise
 */
public static boolean store(Path path,Object data){
  Storage storage=ApplicationContext.getInstance().getStorage();
  try {
    storage.store(path,data);
    return true;
  }
 catch (  Exception e) {
    LOG.log(Level.WARNING,"String_Node_Str" + path,e);
    return false;
  }
}
Program: 7486
Project: 7486
Buggy source:
/** 
 * Creates a new binary string wrapper.
 * @param file           the file to encapsulate
 */
public BinaryString(String data){
  this.data=data;
}

Fixed version (ground truth):
/** 
 * Creates a new binary string wrapper.
 * @param data           the string to encapsulate
 */
public BinaryString(String data){
  this.data=data;
}
Program: 7487
Project: 7487
Buggy source:
/** 
 * Serializes an array into an XML representation.
 * @param id             the data identifier
 * @param arr            the array to convert
 * @param buffer         the string buffer to append into
 */
private static void serialize(String id,Array arr,int indent,StringBuilder buffer){
  tagStart(id,"String_Node_Str",buffer);
  for (int i=0; i < arr.size(); i++) {
    buffer.append("String_Node_Str");
    buffer.append(StringUtils.repeat("String_Node_Str",indent + 1));
    serialize("String_Node_Str",arr.get(i),indent + 1,buffer);
  }
  buffer.append("String_Node_Str");
  buffer.append(StringUtils.repeat("String_Node_Str",indent));
  tagEnd(id,buffer);
}

Fixed version (ground truth):
/** 
 * Serializes an array into an XML representation.
 * @param id             the data identifier
 * @param arr            the array to convert
 * @param indent         the current indentation level
 * @param buffer         the string buffer to append into
 */
private static void serialize(String id,Array arr,int indent,StringBuilder buffer){
  tagStart(id,"String_Node_Str",buffer);
  for (int i=0; i < arr.size(); i++) {
    buffer.append("String_Node_Str");
    buffer.append(StringUtils.repeat("String_Node_Str",indent + 1));
    serialize("String_Node_Str",arr.get(i),indent + 1,buffer);
  }
  buffer.append("String_Node_Str");
  buffer.append(StringUtils.repeat("String_Node_Str",indent));
  tagEnd(id,buffer);
}
Program: 7488
Project: 7488
Buggy source:
/** 
 * Processes a file upload request. This is used when files are POST:ed to the special upload URL.
 * @param request        the request to process
 */
protected void processUpload(Request request){
  Session session=(Session)Session.activeSession.get();
  FileItemStream stream;
  String fileId=request.getPath();
  String fileName;
  File file;
  if (session == null) {
    errorUnauthorized(request);
    return;
  }
  try {
    stream=request.getNextFile();
    if (stream == null) {
      errorBadRequest(request,"String_Node_Str");
      return;
    }
    fileName=stream.getName();
    if (fileName.lastIndexOf("String_Node_Str") >= 0) {
      fileName=fileName.substring(fileName.lastIndexOf("String_Node_Str") + 1);
    }
    if (fileName.lastIndexOf("String_Node_Str") >= 0) {
      fileName=fileName.substring(fileName.lastIndexOf("String_Node_Str") + 1);
    }
    while (fileId != null && fileId.startsWith("String_Node_Str")) {
      fileId=fileId.substring(1);
    }
    if (fileId == null || fileId.trim().length() == 0) {
      fileId=fileName;
    }
    file=FileUtil.tempFile(fileName);
    FileUtil.copy(stream.openStream(),file);
    session.addFile(fileId,file);
    request.sendText(Mime.TEXT[0],"String_Node_Str" + fileId + "String_Node_Str");
  }
 catch (  IOException e) {
    LOG.log(Level.WARNING,"String_Node_Str",e);
    errorBadRequest(request,e.getMessage());
  }
}

Fixed version (ground truth):
/** 
 * Processes a file upload request. This is used when files are POST:ed to the special upload URL.
 * @param request        the request to process
 */
protected void processUpload(Request request){
  Session session=(Session)Session.activeSession.get();
  FileItemStream stream;
  String fileId=request.getPath();
  String fileName;
  File file;
  if (session == null) {
    errorUnauthorized(request);
    return;
  }
  try {
    stream=request.getNextFile();
    if (stream == null) {
      errorBadRequest(request,"String_Node_Str");
      return;
    }
    fileName=stream.getName();
    if (fileName.lastIndexOf("String_Node_Str") >= 0) {
      fileName=fileName.substring(fileName.lastIndexOf("String_Node_Str") + 1);
    }
    if (fileName.lastIndexOf("String_Node_Str") >= 0) {
      fileName=fileName.substring(fileName.lastIndexOf("String_Node_Str") + 1);
    }
    while (fileId != null && fileId.startsWith("String_Node_Str")) {
      fileId=fileId.substring(1);
    }
    if (fileId == null || fileId.trim().length() == 0) {
      fileId=fileName;
    }
    session.removeFile(fileId);
    file=FileUtil.tempFile(fileName);
    FileUtil.copy(stream.openStream(),file);
    session.addFile(fileId,file);
    request.sendText(Mime.TEXT[0],"String_Node_Str" + fileId + "String_Node_Str");
  }
 catch (  IOException e) {
    LOG.log(Level.WARNING,"String_Node_Str",e);
    errorBadRequest(request,e.getMessage());
  }
}
Program: 7489
Project: 7489
Buggy source:
/** 
 * Parses a string with HTTP headers into a result value map.
 * @param map            the result name and value map
 * @param data           the unparsed header string
 */
private static void parseHeaders(LinkedHashMap map,String data){
  StringTokenizer st1;
  StringTokenizer st2;
  st1=new StringTokenizer(data,"String_Node_Str");
  while (st1.hasMoreTokens()) {
    st2=new StringTokenizer(st1.nextToken(),"String_Node_Str");
    map.put(st2.nextToken().trim(),st2.nextToken().trim());
  }
}

Fixed version (ground truth):
/** 
 * Parses a string with HTTP headers into a result value map.
 * @param map            the result name and value map
 * @param data           the unparsed header string
 */
private static void parseHeaders(LinkedHashMap map,String data){
  for (  String line : data.split("String_Node_Str")) {
    String[] parts=line.split("String_Node_Str",2);
    if (parts.length == 2) {
      map.put(parts[0].trim(),parts[1].trim());
    }
  }
}
Program: 7490
Project: 7490
Buggy source:
/** 
 * Finds all binary files of a specified type from the storage. Only binary files in the named subdirectory (i.e. "files/css") with the specified type as suffix (i.e. "*.css") will be returned.
 * @param type           the file type to find
 * @return a sorted list of all matching files (relative paths)found in storage
 */
protected static Array findFileResources(String type){
  ApplicationContext ctx=ApplicationContext.getInstance();
  String root=FileRequestHandler.PATH_FILES.toString();
  Path path=FileRequestHandler.PATH_FILES.child(type,true);
  Metadata[] meta;
  String file;
  Array res=new Array();
  meta=ctx.getStorage().lookupAll(path);
  for (int i=0; i < meta.length; i++) {
    file=StringUtils.removeStart(meta[i].path().toString(),root);
    if (meta[i].isBinary() && file.endsWith("String_Node_Str" + type)) {
      res.add(file);
    }
  }
  res.sort();
  return res;
}

Fixed version (ground truth):
/** 
 * Finds all binary files of a specified type from the storage. Only binary files in the named subdirectory (i.e. "files/css") with the specified type as suffix (i.e. "*.css") will be returned.
 * @param type           the file type to find
 * @return a sorted list of all matching files (relative paths)found in storage
 */
protected static Array findFileResources(String type){
  ApplicationContext ctx=ApplicationContext.getInstance();
  String root=FileRequestHandler.PATH_FILES.toString();
  Path path=FileRequestHandler.PATH_FILES.child(type,true);
  Dict dict;
  Metadata[] meta;
  String file;
  Array res=new Array();
  dict=(Dict)ctx.getStorage().load(PluginManager.PATH_INFO);
  meta=ctx.getStorage().lookupAll(path);
  for (int i=0; i < meta.length; i++) {
    file=StringUtils.removeStart(meta[i].path().toString(),root);
    if (meta[i].isBinary() && file.endsWith("String_Node_Str" + type)) {
      res.add(file + "String_Node_Str" + dict.getString("String_Node_Str","String_Node_Str"));
    }
  }
  res.sort();
  return res;
}
Program: 7492
Project: 7492
Buggy source:
/** 
 * Unmounts a storage from the specified path. The path must have previously been used to mount a storage, which will also be destroyed by this operation.
 * @param path           the mount path
 * @throws StorageException if the storage couldn't be unmounted
 */
public void unmount(Path path) throws StorageException {
  Storage storage=getMountedStorage(path,true);
  String msg;
  if (storage == null) {
    msg="String_Node_Str" + path;
    LOG.warning(msg);
    throw new StorageException(msg);
  }
  updateStorageCache(path,false);
  mountedStorages.remove(mountedStorages.indexOf(storage));
  setMountedStorage(path,null);
}

Fixed version (ground truth):
/** 
 * Unmounts a storage from the specified path. The path must have previously been used to mount a storage, which will also be destroyed by this operation.
 * @param path           the mount path
 * @throws StorageException if the storage couldn't be unmounted
 */
public void unmount(Path path) throws StorageException {
  Storage storage=getMountedStorage(path,true);
  String msg;
  if (storage == null) {
    msg="String_Node_Str" + path;
    LOG.warning(msg);
    throw new StorageException(msg);
  }
  updateStorageCache(path,false);
  mountedStorages.remove(mountedStorages.indexOf(storage));
  setMountedStorage(path,null);
  storage.destroy();
}
Program: 7493
Project: 7493
Buggy source:
/** 
 * Locates the file references by the specified path. If no file is named exactly as the last path name, the properties file extension is appended to the name.
 * @param path           the storage location
 * @return the file referenced by the path, ornull if no existing file was found
 */
private File locateFile(Path path){
  File dir=locateDir(path);
  File file=dir;
  if (!path.isIndex()) {
    file=new File(dir,path.name());
    if (!file.canRead()) {
      file=new File(dir,path.name() + SUFFIX_PROPS);
    }
  }
  return file.canRead() ? file : null;
}

Fixed version (ground truth):
/** 
 * Locates the file references by the specified path. If no file is named exactly as the last path name, the properties file extension is appended to the name.
 * @param path           the storage location
 * @return the file referenced by the path, ornull if no existing file was found
 */
private File locateFile(Path path){
  File dir=locateDir(path);
  File file=dir;
  if (!path.isIndex()) {
    file=new File(dir,path.name());
    if (!file.canRead()) {
      file=new File(dir,path.name() + SUFFIX_PROPS);
    }
  }
  if (file.isDirectory() != path.isIndex()) {
    return null;
  }
 else {
    return file.canRead() ? file : null;
  }
}
Program: 7495
Project: 7495
Buggy source:
/** 
 * Executes a call of this procedure in the specified context and with the specified call bindings. The semantics of what the procedure actually does, is up to each implementation. Note that the call bindings are normally inherited from the procedure bindings with arguments bound to their call values.
 * @param cx             the procedure call context
 * @param bindings       the call bindings to use
 * @return the result of the call, ornull if the call produced no result
 * @throws ProcedureException if the call execution caused anerror
 */
public Object call(CallContext cx,Bindings bindings) throws ProcedureException {
  Library library=cx.getLibrary();
  String[] names;
  Array list;
  names=library.getProcedureNames();
  list=new Array(names.length);
  for (int i=0; i < names.length; i++) {
    if (SecurityContext.hasAccess("String_Node_Str",names[i],"String_Node_Str")) {
      list.add(names[i]);
    }
  }
  list.sort();
  return list;
}

Fixed version (ground truth):
/** 
 * Executes a call of this procedure in the specified context and with the specified call bindings. The semantics of what the procedure actually does, is up to each implementation. Note that the call bindings are normally inherited from the procedure bindings with arguments bound to their call values.
 * @param cx             the procedure call context
 * @param bindings       the call bindings to use
 * @return the result of the call, ornull if the call produced no result
 * @throws ProcedureException if the call execution caused anerror
 */
public Object call(CallContext cx,Bindings bindings) throws ProcedureException {
  Library library=cx.getLibrary();
  String[] names;
  Array list;
  names=library.getProcedureNames();
  list=new Array(names.length);
  for (int i=0; i < names.length; i++) {
    if (library.hasBuiltIn(names[i])) {
      if (SecurityContext.hasAccess(library.getProcedure(names[i]))) {
        list.add(names[i]);
      }
    }
 else     if (SecurityContext.hasAccess("String_Node_Str",names[i],"String_Node_Str")) {
      list.add(names[i]);
    }
  }
  list.sort();
  return list;
}
Program: 7496
Project: 7496
Buggy source:
/** 
 * Prepares an SQL statement.
 * @param sql            the SQL statement to prepare
 * @param params         the optional list of parameters
 * @return the prepared SQL statement
 * @throws ConnectionException if the statement couldn't be prepared
 */
protected PreparedStatement prepare(String sql,ArrayList params) throws ConnectionException {
  PreparedStatement stmt;
  Object obj;
  String str;
  try {
    stmt=con.prepareStatement(sql,ResultSet.TYPE_FORWARD_ONLY,ResultSet.CONCUR_READ_ONLY,ResultSet.CLOSE_CURSORS_AT_COMMIT);
    for (int i=0; params != null && i < params.size(); i++) {
      obj=params.get(i);
      if (obj instanceof String && ((String)obj).length() > 255) {
        str=(String)params.get(i);
        stmt.setCharacterStream(i + 1,new StringReader(str),str.length());
      }
 else {
        stmt.setObject(i + 1,obj);
      }
    }
    stmt.setQueryTimeout(timeout);
    stmt.setFetchSize(Integer.MIN_VALUE);
    return stmt;
  }
 catch (  SQLException e) {
    str="String_Node_Str" + e.getMessage();
    throw new ConnectionException(str);
  }
}

Fixed version (ground truth):
/** 
 * Prepares an SQL statement.
 * @param sql            the SQL statement to prepare
 * @param params         the optional list of parameters
 * @return the prepared SQL statement
 * @throws ConnectionException if the statement couldn't be prepared
 */
protected PreparedStatement prepare(String sql,ArrayList params) throws ConnectionException {
  PreparedStatement stmt;
  Object obj;
  String str;
  try {
    stmt=con.prepareStatement(sql,ResultSet.TYPE_FORWARD_ONLY,ResultSet.CONCUR_READ_ONLY,ResultSet.CLOSE_CURSORS_AT_COMMIT);
    for (int i=0; params != null && i < params.size(); i++) {
      obj=params.get(i);
      if (obj instanceof String && ((String)obj).length() > 255) {
        str=(String)params.get(i);
        stmt.setCharacterStream(i + 1,new StringReader(str),str.length());
      }
 else {
        stmt.setObject(i + 1,obj);
      }
    }
    stmt.setQueryTimeout(timeout);
    return stmt;
  }
 catch (  SQLException e) {
    str="String_Node_Str" + e.getMessage();
    throw new ConnectionException(str);
  }
}