nus-yam/ex-repair huggingface dataset:
Program: 151224
Project: 151224
Buggy source:
/** 
 * Traverses world inheritance depth-first.
 * @param entity Entity to perform local action on
 * @return Any detected results
 */
private Return traverseWorldInheritance(PermissionEntity entity){
  List<String> worldInheritance=entity.manager.getWorldInheritance(world);
  if (worldInheritance.size() > 0) {
    Deque<String> worlds=new LinkedList<String>(worldInheritance);
    Set<String> visitedWorlds=new HashSet<String>();
    Return ret=null;
    while (!worlds.isEmpty()) {
      String current=worlds.removeFirst();
      if (visitedWorlds.contains(current)) {
        if (entity.isDebug()) {
          entity.manager.getLogger().warning("String_Node_Str" + current);
        }
        continue;
      }
      visitedWorlds.add(current);
      ret=fetchLocal(entity,current);
      if (ret != null) {
        break;
      }
      final List<String> nextLevel=entity.manager.getWorldInheritance(current);
      for (int i=nextLevel.size() - 1; i >= 0; --i) {
        worlds.add(nextLevel.get(i));
      }
    }
    return ret;
  }
  return null;
}

Fixed version (ground truth):
/** 
 * Traverses world inheritance depth-first.
 * @param entity Entity to perform local action on
 * @return Any detected results
 */
private Return traverseWorldInheritance(PermissionEntity entity){
  List<String> worldInheritance=entity.manager.getWorldInheritance(world);
  if (worldInheritance.size() > 0) {
    Deque<String> worlds=new LinkedList<>(worldInheritance);
    Set<String> visitedWorlds=new HashSet<>();
    Return ret=null;
    while (!worlds.isEmpty()) {
      String current=worlds.removeFirst();
      if (visitedWorlds.contains(current)) {
        if (entity.isDebug()) {
          entity.manager.getLogger().warning("String_Node_Str" + current);
        }
        continue;
      }
      visitedWorlds.add(current);
      ret=fetchLocal(entity,current);
      if (ret != null) {
        break;
      }
      final List<String> nextLevel=entity.manager.getWorldInheritance(current);
      for (int i=nextLevel.size() - 1; i >= 0; --i) {
        worlds.add(nextLevel.get(i));
      }
    }
    return ret;
  }
  return null;
}
Program: 151225
Project: 151225
Buggy source:
protected List<String> getPermissionsInternal(String worldName,final boolean filterNonInheritable){
  final List<String> ret=new ArrayList<String>();
  new HierarchyTraverser<Void>(this,worldName){
    @Override protected Void fetchLocal(    PermissionEntity entity,    String world){
      for (      String perm : entity.getOwnPermissions(world)) {
        if (filterNonInheritable && entity != PermissionEntity.this && perm.startsWith(NON_INHERITABLE_PREFIX)) {
          continue;
        }
        ret.add(perm);
        getInheritedChildPermissions(perm,ret);
      }
      for (      String perm : entity.getTimedPermissions(world)) {
        if (filterNonInheritable && entity != PermissionEntity.this && perm.startsWith(NON_INHERITABLE_PREFIX)) {
          continue;
        }
        ret.add(perm);
        getInheritedChildPermissions(perm,ret);
      }
      return null;
    }
  }
.traverse();
  return ret;
}

Fixed version (ground truth):
protected List<String> getPermissionsInternal(String worldName,final boolean filterNonInheritable){
  final List<String> ret=new ArrayList<>();
  new HierarchyTraverser<Void>(this,worldName){
    @Override protected Void fetchLocal(    PermissionEntity entity,    String world){
      for (      String perm : entity.getOwnPermissions(world)) {
        if (filterNonInheritable && entity != PermissionEntity.this && perm.startsWith(NON_INHERITABLE_PREFIX)) {
          continue;
        }
        ret.add(perm);
        getInheritedChildPermissions(perm,ret);
      }
      for (      String perm : entity.getTimedPermissions(world)) {
        if (filterNonInheritable && entity != PermissionEntity.this && perm.startsWith(NON_INHERITABLE_PREFIX)) {
          continue;
        }
        ret.add(perm);
        getInheritedChildPermissions(perm,ret);
      }
      return null;
    }
  }
.traverse();
  return ret;
}
Program: 151226
Project: 151226
Buggy source:
public double getOwnOptionDouble(String optionName,String world,double defaultValue){
  String option=this.getOwnOption(optionName,world,Double.toString(defaultValue));
  try {
    return Double.parseDouble(option);
  }
 catch (  NumberFormatException e) {
  }
  return defaultValue;
}

Fixed version (ground truth):
public double getOwnOptionDouble(String optionName,String world,double defaultValue){
  String option=this.getOwnOption(optionName,world,Double.toString(defaultValue));
  try {
    return Double.parseDouble(option);
  }
 catch (  NumberFormatException ignore) {
  }
  return defaultValue;
}
Program: 151227
Project: 151227
Buggy source:
protected List<PermissionGroup> getWorldParents(String worldName){
  List<PermissionGroup> groups=new LinkedList<PermissionGroup>();
  for (  String groupName : getData().getParents(worldName)) {
    if (groupName == null || groupName.trim().isEmpty() || (this instanceof PermissionGroup && groupName.equalsIgnoreCase(this.getIdentifier()))) {
      continue;
    }
    PermissionGroup group=this.manager.getGroup(groupName);
    if (!groups.contains(group)) {
      groups.add(group);
    }
  }
  Collections.sort(groups);
  return Collections.unmodifiableList(groups);
}

Fixed version (ground truth):
protected List<PermissionGroup> getWorldParents(String worldName){
  List<PermissionGroup> groups=new LinkedList<>();
  for (  String groupName : getData().getParents(worldName)) {
    if (groupName == null || groupName.trim().isEmpty() || (this instanceof PermissionGroup && groupName.equalsIgnoreCase(this.getIdentifier()))) {
      continue;
    }
    PermissionGroup group=this.manager.getGroup(groupName);
    if (!groups.contains(group)) {
      groups.add(group);
    }
  }
  Collections.sort(groups);
  return Collections.unmodifiableList(groups);
}
Program: 151228
Project: 151228
Buggy source:
/** 
 * Returns remaining lifetime of specified permission in world
 * @param permission Name of permission
 * @param world
 * @return remaining lifetime in seconds of timed permission. 0 if permission is transient
 */
public int getTimedPermissionLifetime(String permission,String world){
  if (world == null) {
    world="String_Node_Str";
  }
  if (!this.timedPermissionsTime.containsKey(world + "String_Node_Str" + permission)) {
    return 0;
  }
  return (int)(this.timedPermissionsTime.get(world + "String_Node_Str" + permission).longValue() - (System.currentTimeMillis() / 1000L));
}

Fixed version (ground truth):
/** 
 * Returns remaining lifetime of specified permission in world
 * @param permission Name of permission
 * @param world
 * @return remaining lifetime in seconds of timed permission. 0 if permission is transient
 */
public int getTimedPermissionLifetime(String permission,String world){
  if (world == null) {
    world="String_Node_Str";
  }
  if (!this.timedPermissionsTime.containsKey(world + "String_Node_Str" + permission)) {
    return 0;
  }
  return (int)(this.timedPermissionsTime.get(world + "String_Node_Str" + permission) - (System.currentTimeMillis() / 1000L));
}
Program: 151229
Project: 151229
Buggy source:
public int getOwnOptionInteger(String optionName,String world,int defaultValue){
  String option=this.getOwnOption(optionName,world,Integer.toString(defaultValue));
  try {
    return Integer.parseInt(option);
  }
 catch (  NumberFormatException e) {
  }
  return defaultValue;
}

Fixed version (ground truth):
public int getOwnOptionInteger(String optionName,String world,int defaultValue){
  String option=this.getOwnOption(optionName,world,Integer.toString(defaultValue));
  try {
    return Integer.parseInt(option);
  }
 catch (  NumberFormatException ignore) {
  }
  return defaultValue;
}
Program: 151230
Project: 151230
Buggy source:
protected List<PermissionGroup> getParentsInternal(String world){
  final List<PermissionGroup> ret=new ArrayList<PermissionGroup>();
  new HierarchyTraverser<Void>(this,world,false){
    @Override protected Void fetchLocal(    PermissionEntity entity,    String world){
      for (      String groupName : entity.getOwnParentIdentifiers(world)) {
        if (groupName == null || groupName.trim().isEmpty() || (PermissionEntity.this instanceof PermissionGroup && groupName.equalsIgnoreCase(getIdentifier()))) {
          continue;
        }
        PermissionGroup group=manager.getGroup(groupName);
        if (!ret.contains(group)) {
          ret.add(group);
        }
      }
      return null;
    }
  }
.traverse();
  Collections.sort(ret);
  return ret;
}

Fixed version (ground truth):
protected List<PermissionGroup> getParentsInternal(String world){
  final List<PermissionGroup> ret=new ArrayList<>();
  new HierarchyTraverser<Void>(this,world,false){
    @Override protected Void fetchLocal(    PermissionEntity entity,    String world){
      for (      String groupName : entity.getOwnParentIdentifiers(world)) {
        if (groupName == null || groupName.trim().isEmpty() || (PermissionEntity.this instanceof PermissionGroup && groupName.equalsIgnoreCase(getIdentifier()))) {
          continue;
        }
        PermissionGroup group=manager.getGroup(groupName);
        if (!ret.contains(group)) {
          ret.add(group);
        }
      }
      return null;
    }
  }
.traverse();
  Collections.sort(ret);
  return ret;
}
Program: 151231
Project: 151231
Buggy source:
/** 
 * Return integer value for option
 * @param optionName
 * @param world
 * @param defaultValue
 * @return option value or defaultValue if option was not found or is not integer
 */
public int getOptionInteger(String optionName,String world,int defaultValue){
  try {
    return Integer.parseInt(this.getOption(optionName,world,Integer.toString(defaultValue)));
  }
 catch (  NumberFormatException e) {
  }
  return defaultValue;
}

Fixed version (ground truth):
/** 
 * Return integer value for option
 * @param optionName
 * @param world
 * @param defaultValue
 * @return option value or defaultValue if option was not found or is not integer
 */
public int getOptionInteger(String optionName,String world,int defaultValue){
  try {
    return Integer.parseInt(this.getOption(optionName,world,Integer.toString(defaultValue)));
  }
 catch (  NumberFormatException ignore) {
  }
  return defaultValue;
}
Program: 151232
Project: 151232
Buggy source:
/** 
 * Returns double value for option
 * @param optionName
 * @param world
 * @param defaultValue
 * @return option value or defaultValue if option was not found or is not double
 */
public double getOptionDouble(String optionName,String world,double defaultValue){
  String option=this.getOption(optionName,world,Double.toString(defaultValue));
  try {
    return Double.parseDouble(option);
  }
 catch (  NumberFormatException e) {
  }
  return defaultValue;
}

Fixed version (ground truth):
/** 
 * Returns double value for option
 * @param optionName
 * @param world
 * @param defaultValue
 * @return option value or defaultValue if option was not found or is not double
 */
public double getOptionDouble(String optionName,String world,double defaultValue){
  String option=this.getOption(optionName,world,Double.toString(defaultValue));
  try {
    return Double.parseDouble(option);
  }
 catch (  NumberFormatException ignore) {
  }
  return defaultValue;
}
Program: 151233
Project: 151233
Buggy source:
protected void getInheritedChildPermissions(Permission perm,List<String> list,boolean invert){
  if (perm == null) {
    return;
  }
  for (  Map.Entry<String,Boolean> entry : perm.getChildren().entrySet()) {
    boolean has=entry.getValue().booleanValue() ^ invert;
    String node=(has ? "String_Node_Str" : "String_Node_Str") + entry.getKey();
    if (!list.contains(node)) {
      list.add(node);
      getInheritedChildPermissions(node,list,!has);
    }
  }
}

Fixed version (ground truth):
protected void getInheritedChildPermissions(Permission perm,List<String> list,boolean invert){
  if (perm == null) {
    return;
  }
  for (  Map.Entry<String,Boolean> entry : perm.getChildren().entrySet()) {
    boolean has=entry.getValue() ^ invert;
    String node=(has ? "String_Node_Str" : "String_Node_Str") + entry.getKey();
    if (!list.contains(node)) {
      list.add(node);
      getInheritedChildPermissions(node,list,!has);
    }
  }
}
Program: 151234
Project: 151234
Buggy source:
public Map<String,List<PermissionGroup>> getAllParents(){
  Map<String,List<PermissionGroup>> allGroups=new HashMap<String,List<PermissionGroup>>();
  for (  String worldName : this.getWorlds()) {
    allGroups.put(worldName,this.getWorldParents(worldName));
  }
  allGroups.put(null,this.getWorldParents(null));
  return Collections.unmodifiableMap(allGroups);
}

Fixed version (ground truth):
public Map<String,List<PermissionGroup>> getAllParents(){
  Map<String,List<PermissionGroup>> allGroups=new HashMap<>();
  for (  String worldName : this.getWorlds()) {
    allGroups.put(worldName,this.getWorldParents(worldName));
  }
  allGroups.put(null,this.getWorldParents(null));
  return Collections.unmodifiableMap(allGroups);
}
Program: 151235
Project: 151235
Buggy source:
private void clearChildren(String worldName){
  for (  PermissionGroup group : this.getChildGroups(worldName)) {
    List<PermissionGroup> parentGroups=new LinkedList<PermissionGroup>(group.getOwnParents(worldName));
    parentGroups.remove(this);
    group.setParents(parentGroups,worldName);
  }
  for (  PermissionUser user : this.getUsers(worldName)) {
    user.removeGroup(this,worldName);
  }
}

Fixed version (ground truth):
private void clearChildren(String worldName){
  for (  PermissionGroup group : this.getChildGroups(worldName)) {
    List<PermissionGroup> parentGroups=new LinkedList<>(group.getOwnParents(worldName));
    parentGroups.remove(this);
    group.setParents(parentGroups,worldName);
  }
  for (  PermissionUser user : this.getUsers(worldName)) {
    user.removeGroup(this,worldName);
  }
}
Program: 151236
Project: 151236
Buggy source:
@Override public boolean setIdentifier(String identifier){
  ConfigurationSection section=findExistingNode(identifier,false);
  if (section != null) {
    return false;
  }
  this.nodePath=FileBackend.buildPath(basePath,identifier);
  this.entityName=identifier;
  if (!this.isVirtual()) {
    this.config.set(nodePath,node);
    this.save();
  }
  return true;
}

Fixed version (ground truth):
@Override public boolean setIdentifier(String identifier){
  ConfigurationSection section=findExistingNode(identifier,false);
  if (section != null) {
    return false;
  }
  String oldNodePath=this.nodePath;
  this.nodePath=FileBackend.buildPath(basePath,identifier);
  this.entityName=identifier;
  if (!this.isVirtual()) {
    this.config.set(nodePath,node);
    this.config.set(oldNodePath,null);
    this.save();
  }
  return true;
}
Program: 151237
Project: 151237
Buggy source:
protected void updateInfo(){
  String sql;
  if (this.isVirtual()) {
    sql="String_Node_Str";
  }
 else {
    sql="String_Node_Str";
  }
  try (SQLConnection conn=backend.getSQL()){
    conn.prepAndBind(sql,this.prefix,this.suffix,this.def ? 1 : 0,this.getIdentifier(),this.type.ordinal()).execute();
  }
 catch (  SQLException e) {
    if (this.isVirtual()) {
      this.virtual=false;
      this.updateInfo();
    }
    throw new RuntimeException(e);
  }
  this.virtual=false;
}

Fixed version (ground truth):
protected void updateInfo(){
  String sql;
  if (this.isVirtual()) {
    sql="String_Node_Str";
  }
 else {
    sql="String_Node_Str";
  }
  try (SQLConnection conn=backend.getSQL()){
    conn.prepAndBind(sql,nullToEmpty(this.prefix),nullToEmpty(this.suffix),this.def ? 1 : 0,this.getIdentifier(),this.type.ordinal()).execute();
  }
 catch (  SQLException e) {
    if (this.isVirtual()) {
      this.virtual=false;
      this.updateInfo();
    }
    throw new RuntimeException(e);
  }
  this.virtual=false;
}
Program: 151238
Project: 151238
Buggy source:
private String nullToEmpty(String enter){
  if (enter == null || enter.equals("String_Node_Str")) {
    return null;
  }
  return enter;
}

Fixed version (ground truth):
private String nullToEmpty(String enter){
  if (enter == null) {
    return "String_Node_Str";
  }
  return enter;
}
Program: 151239
Project: 151239
Buggy source:
protected final void fetchInfo(){
  try (SQLConnection conn=backend.getSQL()){
    ResultSet result=conn.prepAndBind("String_Node_Str",this.getIdentifier(),this.type.ordinal()).executeQuery();
    if (result.next()) {
      this.prefix=nullToEmpty(result.getString("String_Node_Str"));
      this.suffix=nullToEmpty(result.getString("String_Node_Str"));
      this.def=result.getBoolean("String_Node_Str");
      this.identifier=result.getString("String_Node_Str");
      this.virtual=false;
    }
 else {
      this.prefix="String_Node_Str";
      this.suffix="String_Node_Str";
      this.virtual=true;
    }
  }
 catch (  SQLException e) {
    throw new RuntimeException(e);
  }
}

Fixed version (ground truth):
protected final void fetchInfo(){
  try (SQLConnection conn=backend.getSQL()){
    ResultSet result=conn.prepAndBind("String_Node_Str",this.getIdentifier(),this.type.ordinal()).executeQuery();
    if (result.next()) {
      this.prefix=emptyToNull(result.getString("String_Node_Str"));
      this.suffix=emptyToNull(result.getString("String_Node_Str"));
      this.def=result.getBoolean("String_Node_Str");
      this.identifier=result.getString("String_Node_Str");
      this.virtual=false;
    }
 else {
      this.prefix="String_Node_Str";
      this.suffix="String_Node_Str";
      this.virtual=true;
    }
  }
 catch (  SQLException e) {
    throw new RuntimeException(e);
  }
}
Program: 151240
Project: 151240
Buggy source:
@Override public void initialize() throws PermissionBackendException {
  PermissionsEx plugin=PermissionsEx.getPlugin();
  String permissionFilename=config.getString("String_Node_Str");
  if (permissionFilename == null) {
    permissionFilename="String_Node_Str";
    config.set("String_Node_Str","String_Node_Str");
  }
  String baseDir=config.getString("String_Node_Str",plugin.getDataFolder());
  if (baseDir.contains("String_Node_Str") && !"String_Node_Str".equals(File.separator)) {
    baseDir=baseDir.replace("String_Node_Str",File.separator);
  }
  File baseDirectory=new File(baseDir);
  if (!baseDirectory.exists()) {
    baseDirectory.mkdirs();
  }
  this.permissionsFile=new File(baseDir,permissionFilename);
  this.reload();
}

Fixed version (ground truth):
@Override public void initialize() throws PermissionBackendException {
  Plugin plugin=PermissionsEx.getPlugin();
  String permissionFilename=config.getString("String_Node_Str");
  if (permissionFilename == null) {
    permissionFilename="String_Node_Str";
    config.set("String_Node_Str","String_Node_Str");
  }
  String baseDir=config.getString("String_Node_Str",plugin.getDataFolder().getPath());
  if (baseDir.contains("String_Node_Str") && !"String_Node_Str".equals(File.separator)) {
    baseDir=baseDir.replace("String_Node_Str",File.separator);
  }
  File baseDirectory=new File(baseDir);
  if (!baseDirectory.exists()) {
    baseDirectory.mkdirs();
  }
  this.permissionsFile=new File(baseDir,permissionFilename);
  this.reload();
}
Program: 151241
Project: 151241
Buggy source:
@Override public String getMatchingExpression(String permission,String world){
  String cacheId=world + "String_Node_Str" + permission;
  if (!this.cachedAnwsers.containsKey(cacheId)) {
    this.cachedAnwsers.put(cacheId,super.getMatchingExpression(permission,world));
  }
  return this.cachedAnwsers.get(cacheId);
}

Fixed version (ground truth):
@Override public String getMatchingExpression(String permission,String world){
  String cacheId=world + "String_Node_Str" + permission;
  if (!this.cachedAnwsers.containsKey(cacheId)) {
    String result=super.getMatchingExpression(permission,world);
    if (result == null) {
      result=PERMISSION_NOT_FOUND;
    }
    this.cachedAnwsers.put(cacheId,result);
  }
  String result=this.cachedAnwsers.get(cacheId);
  if (PERMISSION_NOT_FOUND.equals(result)) {
    result=null;
  }
  return result;
}
Program: 151242
Project: 151242
Buggy source:
@Override public void setDefaultGroup(PermissionGroup group,String worldName){
  ConfigurationSection groups=this.permissions.getConfigurationSection("String_Node_Str");
  String defaultGroupProperty="String_Node_Str";
  if (worldName != null) {
    defaultGroupProperty="String_Node_Str" + worldName + "String_Node_Str"+ defaultGroupProperty;
  }
  for (  Map.Entry<String,Object> entry : groups.getValues(false).entrySet()) {
    if (entry.getValue() instanceof ConfigurationSection) {
      ConfigurationSection groupSection=(ConfigurationSection)entry.getValue();
      groupSection.set(defaultGroupProperty,false);
      if (!entry.getValue().equals(group.getName())) {
        groupSection.set(defaultGroupProperty,null);
      }
 else {
        groupSection.set(defaultGroupProperty,true);
      }
    }
  }
  this.save();
}

Fixed version (ground truth):
@Override public void setDefaultGroup(PermissionGroup group,String worldName){
  ConfigurationSection groups=this.permissions.getConfigurationSection("String_Node_Str");
  String defaultGroupProperty="String_Node_Str";
  if (worldName != null) {
    defaultGroupProperty=buildPath("String_Node_Str",worldName,defaultGroupProperty);
  }
  for (  Map.Entry<String,Object> entry : groups.getValues(false).entrySet()) {
    if (entry.getValue() instanceof ConfigurationSection) {
      ConfigurationSection groupSection=(ConfigurationSection)entry.getValue();
      groupSection.set(defaultGroupProperty,false);
      if (!entry.getValue().equals(group.getName())) {
        groupSection.set(defaultGroupProperty,null);
      }
 else {
        groupSection.set(defaultGroupProperty,true);
      }
    }
  }
  this.save();
}
Program: 151243
Project: 151243
Buggy source:
@Override public PermissionGroup getDefaultGroup(String worldName){
  ConfigurationSection groups=this.permissions.getConfigurationSection("String_Node_Str");
  if (groups == null) {
    throw new RuntimeException("String_Node_Str");
  }
  String defaultGroupProperty="String_Node_Str";
  if (worldName != null) {
    defaultGroupProperty="String_Node_Str" + worldName + "String_Node_Str"+ defaultGroupProperty;
  }
  for (  Map.Entry<String,Object> entry : groups.getValues(false).entrySet()) {
    if (entry.getValue() instanceof ConfigurationSection) {
      ConfigurationSection groupSection=(ConfigurationSection)entry.getValue();
      if (groupSection.getBoolean(defaultGroupProperty,false)) {
        return this.manager.getGroup(entry.getKey());
      }
    }
  }
  if (worldName == null) {
    throw new RuntimeException("String_Node_Str");
  }
  return null;
}

Fixed version (ground truth):
@Override public PermissionGroup getDefaultGroup(String worldName){
  ConfigurationSection groups=this.permissions.getConfigurationSection("String_Node_Str");
  if (groups == null) {
    throw new RuntimeException("String_Node_Str");
  }
  String defaultGroupProperty="String_Node_Str";
  if (worldName != null) {
    defaultGroupProperty=buildPath("String_Node_Str",worldName,defaultGroupProperty);
  }
  for (  Map.Entry<String,Object> entry : groups.getValues(false).entrySet()) {
    if (entry.getValue() instanceof ConfigurationSection) {
      ConfigurationSection groupSection=(ConfigurationSection)entry.getValue();
      if (groupSection.getBoolean(defaultGroupProperty,false)) {
        return this.manager.getGroup(entry.getKey());
      }
    }
  }
  if (worldName == null) {
    throw new RuntimeException("String_Node_Str");
  }
  return null;
}
Program: 151244
Project: 151244
Buggy source:
@Override public String[] getWorldInheritance(String world){
  if (world != null && !world.isEmpty()) {
    List<String> parentWorlds=this.permissions.getStringList("String_Node_Str" + world + "String_Node_Str");
    if (parentWorlds != null) {
      return parentWorlds.toArray(new String[parentWorlds.size()]);
    }
  }
  return new String[0];
}

Fixed version (ground truth):
@Override public String[] getWorldInheritance(String world){
  if (world != null && !world.isEmpty()) {
    List<String> parentWorlds=this.permissions.getStringList(buildPath("String_Node_Str",world,"String_Node_Str"));
    if (parentWorlds != null) {
      return parentWorlds.toArray(new String[parentWorlds.size()]);
    }
  }
  return new String[0];
}
Program: 151245
Project: 151245
Buggy source:
@Override public void reload(){
  permissions=YamlConfiguration.loadConfiguration(permissionsFile);
  permissions.options().pathSeparator('/');
}

Fixed version (ground truth):
@Override public void reload(){
  permissions=new YamlConfiguration();
  permissions.options().pathSeparator(PATH_SEPARATOR);
  try {
    permissions.load(permissionsFile);
  }
 catch (  Throwable e) {
    throw new IllegalStateException("String_Node_Str",e);
  }
}
Program: 151246
Project: 151246
Buggy source:
@Override public void setWorldInheritance(String world,String[] parentWorlds){
  if (world == null && world.isEmpty()) {
    return;
  }
  this.permissions.set("String_Node_Str" + world + "String_Node_Str",Arrays.asList(parentWorlds));
  this.save();
}

Fixed version (ground truth):
@Override public void setWorldInheritance(String world,String[] parentWorlds){
  if (world == null && world.isEmpty()) {
    return;
  }
  this.permissions.set(buildPath("String_Node_Str",world,"String_Node_Str"),Arrays.asList(parentWorlds));
  this.save();
}
Program: 151247
Project: 151247
Buggy source:
@Override public void setOption(String option,String value,String world){
  String path="String_Node_Str";
  if (world != null && !world.isEmpty()) {
    path="String_Node_Str" + world + "String_Node_Str"+ path;
  }
  path+="String_Node_Str" + option;
  if (value != null && !value.isEmpty()) {
    this.node.set(path,value);
  }
 else {
    this.node.set(path,null);
  }
  this.save();
}

Fixed version (ground truth):
@Override public void setOption(String option,String value,String world){
  this.node.set(formatPath(world,"String_Node_Str",option),value);
  this.save();
}
Program: 151248
Project: 151248
Buggy source:
@Override public String getPrefix(String worldName){
  String prefixNode="String_Node_Str";
  if (worldName != null && !worldName.isEmpty()) {
    prefixNode="String_Node_Str" + worldName + "String_Node_Str"+ prefixNode;
  }
  return this.node.getString(prefixNode);
}

Fixed version (ground truth):
@Override public String getPrefix(String worldName){
  return this.node.getString(formatPath(worldName,"String_Node_Str"));
}
Program: 151249
Project: 151249
Buggy source:
@Override public String[] getPermissions(String world){
  String permissionsNode="String_Node_Str";
  if (world != null && !world.isEmpty()) {
    permissionsNode="String_Node_Str" + world + "String_Node_Str"+ permissionsNode;
  }
  List<String> permissions=this.node.getStringList(permissionsNode);
  if (permissions == null) {
    return new String[0];
  }
  return permissions.toArray(new String[permissions.size()]);
}

Fixed version (ground truth):
@Override public String[] getPermissions(String world){
  List<String> permissions=this.node.getStringList(formatPath(world,"String_Node_Str"));
  if (permissions == null) {
    return new String[0];
  }
  return permissions.toArray(new String[permissions.size()]);
}
Program: 151250
Project: 151250
Buggy source:
@Override public String getOption(String option,String world,String defaultValue){
  return this.node.getString((world == null ? "String_Node_Str" : "String_Node_Str" + world + "String_Node_Str") + "String_Node_Str" + option,defaultValue);
}

Fixed version (ground truth):
@Override public String getOption(String option,String world,String defaultValue){
  return this.node.getString(formatPath(world,"String_Node_Str",option),defaultValue);
}
Program: 151251
Project: 151251
Buggy source:
@Override public void setPermissions(String[] permissions,String world){
  String permissionsNode="String_Node_Str";
  if (world != null && !world.isEmpty()) {
    permissionsNode="String_Node_Str" + world + "String_Node_Str"+ permissionsNode;
  }
  if (permissions.length > 0) {
    this.node.set(permissionsNode,Arrays.asList(permissions));
  }
 else {
    this.node.set(permissionsNode,null);
  }
  this.save();
}

Fixed version (ground truth):
@Override public void setPermissions(String[] permissions,String world){
  this.node.set(formatPath(world,"String_Node_Str"),permissions.length > 0 ? Arrays.asList(permissions) : null);
  this.save();
}
Program: 151252
Project: 151252
Buggy source:
@Override public Map<String,String[]> getAllPermissions(){
  Map<String,String[]> allPermissions=new HashMap<String,String[]>();
  List<String> commonPermissions=this.node.getStringList("String_Node_Str");
  if (commonPermissions != null) {
    allPermissions.put(null,commonPermissions.toArray(new String[0]));
  }
  ConfigurationSection worldsSection=this.node.getConfigurationSection("String_Node_Str");
  if (worldsSection != null) {
    for (    String world : worldsSection.getKeys(false)) {
      List<String> worldPermissions=this.node.getStringList("String_Node_Str" + world + "String_Node_Str");
      if (commonPermissions != null) {
        allPermissions.put(world,worldPermissions.toArray(new String[0]));
      }
    }
  }
  return allPermissions;
}

Fixed version (ground truth):
@Override public Map<String,String[]> getAllPermissions(){
  Map<String,String[]> allPermissions=new HashMap<String,String[]>();
  List<String> commonPermissions=this.node.getStringList("String_Node_Str");
  if (commonPermissions != null) {
    allPermissions.put(null,commonPermissions.toArray(new String[0]));
  }
  ConfigurationSection worldsSection=this.node.getConfigurationSection("String_Node_Str");
  if (worldsSection != null) {
    for (    String world : worldsSection.getKeys(false)) {
      List<String> worldPermissions=this.node.getStringList(FileBackend.buildPath("String_Node_Str",world,"String_Node_Str"));
      if (commonPermissions != null) {
        allPermissions.put(world,worldPermissions.toArray(new String[0]));
      }
    }
  }
  return allPermissions;
}
Program: 151253
Project: 151253
Buggy source:
@Override public String getSuffix(String worldName){
  String suffixNode="String_Node_Str";
  if (worldName != null && !worldName.isEmpty()) {
    suffixNode="String_Node_Str" + worldName + "String_Node_Str"+ suffixNode;
  }
  return this.node.getString(suffixNode);
}

Fixed version (ground truth):
@Override public String getSuffix(String worldName){
  return this.node.getString(formatPath(worldName,"String_Node_Str"));
}
Program: 151254
Project: 151254
Buggy source:
@Override public void setPrefix(String prefix,String worldName){
  String prefixNode="String_Node_Str";
  if (worldName != null && !worldName.isEmpty()) {
    prefixNode="String_Node_Str" + worldName + "String_Node_Str"+ prefixNode;
  }
  if (prefix != null && !prefix.isEmpty()) {
    this.node.set(prefixNode,prefix);
  }
 else {
    this.node.set(prefixNode,null);
  }
  this.save();
}

Fixed version (ground truth):
@Override public void setPrefix(String prefix,String worldName){
  this.node.set(formatPath(worldName,"String_Node_Str"),prefix);
  this.save();
}
Program: 151255
Project: 151255
Buggy source:
@Override public void setSuffix(String suffix,String worldName){
  String suffixNode="String_Node_Str";
  if (worldName != null && !worldName.isEmpty()) {
    suffixNode="String_Node_Str" + worldName + "String_Node_Str"+ suffixNode;
  }
  if (suffix != null && !suffix.isEmpty()) {
    this.node.set(suffixNode,suffix);
  }
 else {
    this.node.set(suffixNode,null);
  }
  this.save();
}

Fixed version (ground truth):
@Override public void setSuffix(String suffix,String worldName){
  this.node.set(formatPath(worldName,"String_Node_Str"),suffix);
  this.save();
}
Program: 151256
Project: 151256
Buggy source:
protected final ConfigurationSection getNode(String baseNode,String entityName){
  this.nodePath=baseNode + "String_Node_Str" + entityName;
  ConfigurationSection entityNode=backend.permissions.getConfigurationSection(this.nodePath);
  if (entityNode != null) {
    this.virtual=false;
    return entityNode;
  }
  ConfigurationSection users=backend.permissions.getConfigurationSection(baseNode);
  if (users != null) {
    for (    Map.Entry<String,Object> entry : users.getValues(false).entrySet()) {
      if (entry.getKey().equalsIgnoreCase(entityName) && entry.getValue() instanceof ConfigurationSection) {
        this.setName(entry.getKey());
        this.nodePath=baseNode + "String_Node_Str" + this.getName();
        this.virtual=false;
        return (ConfigurationSection)entry.getValue();
      }
    }
  }
  this.virtual=true;
  return backend.permissions.createSection(nodePath);
}

Fixed version (ground truth):
protected final ConfigurationSection getNode(String baseNode,String entityName){
  this.nodePath=FileBackend.buildPath(baseNode,entityName);
  ConfigurationSection entityNode=backend.permissions.getConfigurationSection(this.nodePath);
  if (entityNode != null) {
    this.virtual=false;
    return entityNode;
  }
  ConfigurationSection users=backend.permissions.getConfigurationSection(baseNode);
  if (users != null) {
    for (    Map.Entry<String,Object> entry : users.getValues(false).entrySet()) {
      if (entry.getKey().equalsIgnoreCase(entityName) && entry.getValue() instanceof ConfigurationSection) {
        this.setName(entry.getKey());
        this.nodePath=FileBackend.buildPath(baseNode,this.getName());
        this.virtual=false;
        return (ConfigurationSection)entry.getValue();
      }
    }
  }
  this.virtual=true;
  return backend.permissions.createSection(nodePath);
}
Program: 151257
Project: 151257
Buggy source:
@Override public Map<String,String> getOptions(String world){
  String optionNode=(world == null) ? "String_Node_Str" : "String_Node_Str" + world + "String_Node_Str";
  ConfigurationSection optionsSection=this.node.getConfigurationSection(optionNode);
  if (optionsSection != null) {
    return this.collectOptions(optionsSection);
  }
  return new HashMap<String,String>(0);
}

Fixed version (ground truth):
@Override public Map<String,String> getOptions(String world){
  ConfigurationSection optionsSection=this.node.getConfigurationSection(formatPath(world,"String_Node_Str"));
  if (optionsSection != null) {
    return this.collectOptions(optionsSection);
  }
  return new HashMap<String,String>(0);
}
Program: 151258
Project: 151258
Buggy source:
@Override public void setParentGroups(String[] parentGroups,String worldName){
  if (parentGroups == null) {
    return;
  }
  String inheritanceNode="String_Node_Str";
  if (worldName != null && !worldName.isEmpty()) {
    inheritanceNode="String_Node_Str" + worldName + "String_Node_Str"+ inheritanceNode;
  }
  this.node.set(inheritanceNode,Arrays.asList(parentGroups));
  this.save();
  this.callEvent(PermissionEntityEvent.Action.INHERITANCE_CHANGED);
}

Fixed version (ground truth):
@Override public void setParentGroups(String[] parentGroups,String worldName){
  if (parentGroups == null) {
    return;
  }
  this.node.set(FileEntity.formatPath(worldName,"String_Node_Str"),Arrays.asList(parentGroups));
  this.save();
  this.callEvent(PermissionEntityEvent.Action.INHERITANCE_CHANGED);
}
Program: 151259
Project: 151259
Buggy source:
@Override public String[] getParentGroupsNamesImpl(String worldName){
  String inheritanceNode="String_Node_Str";
  if (worldName != null && !worldName.isEmpty()) {
    inheritanceNode="String_Node_Str" + worldName + "String_Node_Str"+ inheritanceNode;
  }
  List<String> parents=this.node.getStringList(inheritanceNode);
  if (parents.isEmpty()) {
    return new String[0];
  }
  return parents.toArray(new String[parents.size()]);
}

Fixed version (ground truth):
@Override public String[] getParentGroupsNamesImpl(String worldName){
  List<String> parents=this.node.getStringList(FileEntity.formatPath(worldName,"String_Node_Str"));
  if (parents.isEmpty()) {
    return new String[0];
  }
  return parents.toArray(new String[parents.size()]);
}
Program: 151260
Project: 151260
Buggy source:
@Override protected String[] getGroupsNamesImpl(String worldName){
  String inheritanceNode="String_Node_Str";
  if (worldName != null && !worldName.isEmpty()) {
    inheritanceNode="String_Node_Str" + worldName + "String_Node_Str"+ inheritanceNode;
  }
  Object groups=this.node.get(inheritanceNode);
  if (groups instanceof String) {
    String[] groupsArray;
    String groupsString=((String)groups);
    if (groupsString.contains("String_Node_Str")) {
      groupsArray=((String)groups).split("String_Node_Str");
    }
 else {
      groupsArray=new String[]{groupsString};
    }
    this.node.set("String_Node_Str",Arrays.asList(groupsArray));
    this.save();
    return groupsArray;
  }
 else   if (groups instanceof List) {
    return ((List<String>)groups).toArray(new String[0]);
  }
 else {
    return new String[0];
  }
}

Fixed version (ground truth):
@Override protected String[] getGroupsNamesImpl(String worldName){
  Object groups=this.node.get(FileEntity.formatPath(worldName,"String_Node_Str"));
  if (groups instanceof String) {
    String[] groupsArray;
    String groupsString=((String)groups);
    if (groupsString.contains("String_Node_Str")) {
      groupsArray=((String)groups).split("String_Node_Str");
    }
 else {
      groupsArray=new String[]{groupsString};
    }
    this.node.set("String_Node_Str",Arrays.asList(groupsArray));
    this.save();
    return groupsArray;
  }
 else   if (groups instanceof List) {
    return ((List<String>)groups).toArray(new String[0]);
  }
 else {
    return new String[0];
  }
}
Program: 151261
Project: 151261
Buggy source:
@Override public void setGroups(String[] groups,String worldName){
  if (groups == null) {
    return;
  }
  String inheritanceNode="String_Node_Str";
  if (worldName != null && !worldName.isEmpty()) {
    inheritanceNode="String_Node_Str" + worldName + "String_Node_Str"+ inheritanceNode;
  }
  this.node.set(inheritanceNode,Arrays.asList(groups));
  this.save();
  this.callEvent(PermissionEntityEvent.Action.INHERITANCE_CHANGED);
}

Fixed version (ground truth):
@Override public void setGroups(String[] groups,String worldName){
  if (groups == null) {
    return;
  }
  this.node.set(FileEntity.formatPath(worldName,"String_Node_Str"),Arrays.asList(groups));
  this.save();
  this.callEvent(PermissionEntityEvent.Action.INHERITANCE_CHANGED);
}
Program: 151262
Project: 151262
Buggy source:
public void onSystemEvent(PermissionSystemEvent event){
  if (event.getAction() == PermissionSystemEvent.Action.DEBUGMODE_TOGGLE) {
    return;
  }
  updateAllPlayers();
}

Fixed version (ground truth):
@EventHandler(priority=EventPriority.LOW) public void onSystemEvent(PermissionSystemEvent event){
  if (event.getAction() == PermissionSystemEvent.Action.DEBUGMODE_TOGGLE) {
    return;
  }
  updateAllPlayers();
}
Program: 151263
Project: 151263
Buggy source:
@Override public void setDefaultGroup(PermissionGroup group,String worldName){
  ConfigurationSection groups=this.permissions.getConfigurationSection("String_Node_Str");
  String defaultGroupProperty="String_Node_Str";
  if (worldName != null) {
    defaultGroupProperty=buildPath("String_Node_Str",worldName,defaultGroupProperty);
  }
  for (  Map.Entry<String,Object> entry : groups.getValues(false).entrySet()) {
    if (entry.getValue() instanceof ConfigurationSection) {
      ConfigurationSection groupSection=(ConfigurationSection)entry.getValue();
      groupSection.set(defaultGroupProperty,false);
      if (!entry.getValue().equals(group.getName())) {
        groupSection.set(defaultGroupProperty,null);
      }
 else {
        groupSection.set(defaultGroupProperty,true);
      }
    }
  }
  this.save();
}

Fixed version (ground truth):
@Override public void setDefaultGroup(PermissionGroup group,String worldName){
  ConfigurationSection groups=this.permissions.getConfigurationSection("String_Node_Str");
  String defaultGroupProperty="String_Node_Str";
  if (worldName != null) {
    defaultGroupProperty=buildPath("String_Node_Str",worldName,defaultGroupProperty);
  }
  for (  Map.Entry<String,Object> entry : groups.getValues(false).entrySet()) {
    if (entry.getValue() instanceof ConfigurationSection) {
      ConfigurationSection groupSection=(ConfigurationSection)entry.getValue();
      groupSection.set(defaultGroupProperty,false);
      if (!groupSection.getName().equals(group.getName())) {
        groupSection.set(defaultGroupProperty,null);
      }
 else {
        groupSection.set(defaultGroupProperty,true);
      }
    }
  }
  this.save();
}
Program: 151264
Project: 151264
Buggy source:
public void insert(String table,String[] fields,List<Object[]> rows) throws SQLException {
  this.checkConnection();
  String[] fieldPlaceholders=new String[fields.length];
  Arrays.fill(fieldPlaceholders,"String_Node_Str");
  String sql="String_Node_Str" + table + "String_Node_Str"+ StringUtils.implode(fields,"String_Node_Str")+ "String_Node_Str"+ StringUtils.implode(fieldPlaceholders,"String_Node_Str")+ "String_Node_Str";
  PreparedStatement stmt=this.db.prepareStatement(this.prepareQuery(sql));
  for (  Object[] params : rows) {
    this.bindParams(stmt,params);
    stmt.execute();
  }
}

Fixed version (ground truth):
public void insert(String table,String[] fields,List<Object[]> rows) throws SQLException {
  this.checkConnection();
  String[] fieldPlaceholders=new String[fields.length];
  Arrays.fill(fieldPlaceholders,"String_Node_Str");
  String sql="String_Node_Str" + table + "String_Node_Str"+ StringUtils.implode(fields,"String_Node_Str")+ "String_Node_Str"+ StringUtils.implode(fieldPlaceholders,"String_Node_Str")+ "String_Node_Str";
  PreparedStatement stmt=this.db.prepareStatement(this.prepareQuery(sql));
  try {
    for (    Object[] params : rows) {
      this.bindParams(stmt,params);
      stmt.execute();
    }
  }
  finally {
    stmt.close();
  }
}
Program: 151265
Project: 151265
Buggy source:
public void updateQuery(String sql,Object... params){
  try {
    this.checkConnection();
    PreparedStatement stmt=this.db.prepareStatement(this.prepareQuery(sql));
    if (params != null) {
      this.bindParams(stmt,params);
    }
    stmt.executeUpdate();
  }
 catch (  SQLException e) {
    throw new RuntimeException(e);
  }
}

Fixed version (ground truth):
public void updateQuery(String sql,Object... params){
  try {
    this.checkConnection();
    PreparedStatement stmt=this.db.prepareStatement(this.prepareQuery(sql));
    try {
      if (params != null) {
        this.bindParams(stmt,params);
      }
      stmt.executeUpdate();
    }
  finally {
      stmt.close();
    }
  }
 catch (  SQLException e) {
    throw new RuntimeException(e);
  }
}
Program: 151266
Project: 151266
Buggy source:
public ResultSet selectQuery(String sql,Object... params) throws SQLException {
  this.checkConnection();
  PreparedStatement stmt=this.db.prepareStatement(this.prepareQuery(sql));
  if (params != null) {
    this.bindParams(stmt,params);
  }
  return stmt.executeQuery();
}

Fixed version (ground truth):
public ResultSet selectQuery(String sql,Object... params) throws SQLException {
  this.checkConnection();
  PreparedStatement stmt=this.db.prepareStatement(this.prepareQuery(sql));
  try {
    if (params != null) {
      this.bindParams(stmt,params);
    }
    return stmt.executeQuery();
  }
  finally {
    stmt.close();
  }
}
Program: 151267
Project: 151267
Buggy source:
public static String[] getEntitiesNames(SQLConnection sql,Type type,boolean defaultOnly){
  try {
    List<String> entities=new LinkedList<String>();
    ResultSet result=sql.selectQuery("String_Node_Str" + (defaultOnly ? "String_Node_Str" : "String_Node_Str"),type.ordinal());
    while (result.next()) {
      entities.add(result.getString("String_Node_Str"));
    }
    return entities.toArray(new String[0]);
  }
 catch (  SQLException e) {
    throw new RuntimeException(e);
  }
}

Fixed version (ground truth):
public static String[] getEntitiesNames(SQLConnection sql,Type type,boolean defaultOnly){
  try {
    List<String> entities=new LinkedList<String>();
    ResultSet result=sql.selectQuery("String_Node_Str" + (defaultOnly ? "String_Node_Str" : "String_Node_Str"),type.ordinal());
    while (result.next()) {
      entities.add(result.getString("String_Node_Str"));
    }
    result.close();
    return entities.toArray(new String[0]);
  }
 catch (  SQLException e) {
    throw new RuntimeException(e);
  }
}
Program: 151268
Project: 151268
Buggy source:
protected final void fetchInheritance(){
  try {
    this.parents=new HashMap<String,Set<String>>();
    ResultSet results=this.db.selectQuery("String_Node_Str",this.getName(),this.type.ordinal());
    while (results.next()) {
      String parentName=results.getString(1);
      String worldName=results.getString(2);
      if (!this.parents.containsKey(worldName)) {
        this.parents.put(worldName,new HashSet<String>());
      }
      this.parents.get(worldName).add(parentName);
    }
  }
 catch (  SQLException e) {
    throw new RuntimeException(e);
  }
}

Fixed version (ground truth):
protected final void fetchInheritance(){
  try {
    this.parents=new HashMap<String,Set<String>>();
    ResultSet results=this.db.selectQuery("String_Node_Str",this.getName(),this.type.ordinal());
    while (results.next()) {
      String parentName=results.getString(1);
      String worldName=results.getString(2);
      if (!this.parents.containsKey(worldName)) {
        this.parents.put(worldName,new HashSet<String>());
      }
      this.parents.get(worldName).add(parentName);
    }
    results.close();
  }
 catch (  SQLException e) {
    throw new RuntimeException(e);
  }
}