nus-yam/ex-repair huggingface dataset:
Program: 151180
Project: 151180
Buggy source:
@Override public Map<String,List<String>> getPermissionsMap(){
  Map<String,List<String>> allPermissions=new HashMap<String,List<String>>();
  allPermissions.put(null,Collections.unmodifiableList(this.commonPermissions));
  for (  Map.Entry<String,List<String>> entry : this.worldsPermissions.entrySet()) {
    allPermissions.put(entry.getKey(),Collections.unmodifiableList(entry.getValue()));
  }
  return Collections.unmodifiableMap(allPermissions);
}

Fixed version (ground truth):
@Override public Map<String,List<String>> getPermissionsMap(){
  Map<String,List<String>> allPermissions=new HashMap<String,List<String>>();
  if (this.commonPermissions == null) {
    this.fetchPermissions();
  }
  allPermissions.put(null,Collections.unmodifiableList(this.commonPermissions));
  for (  Map.Entry<String,List<String>> entry : this.worldsPermissions.entrySet()) {
    allPermissions.put(entry.getKey(),Collections.unmodifiableList(entry.getValue()));
  }
  return Collections.unmodifiableMap(allPermissions);
}
Program: 151181
Project: 151181
Buggy source:
public SQLData(String name,Type type,SQLBackend backend){
  this.name=name;
  this.type=type;
  this.backend=backend;
}

Fixed version (ground truth):
public SQLData(String name,Type type,SQLBackend backend){
  this.name=name;
  this.type=type;
  this.backend=backend;
  fetchInfo();
}
Program: 151182
Project: 151182
Buggy source:
protected final void fetchInfo(){
  try {
    ResultSet result=this.backend.getSQL().prepAndBind("String_Node_Str",this.getName(),this.type.ordinal()).executeQuery();
    if (result.next()) {
      this.prefix=result.getString("String_Node_Str");
      this.suffix=result.getString("String_Node_Str");
      this.def=result.getBoolean("String_Node_Str");
      this.name=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 {
    ResultSet result=this.backend.getSQL().prepAndBind("String_Node_Str",this.getName(),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.name=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: 151183
Project: 151183
Buggy source:
@Override public Map<String,Map<String,String>> getOptionsMap(){
  Map<String,Map<String,String>> allOptions=new HashMap<String,Map<String,String>>();
  allOptions.put(null,Collections.unmodifiableMap(this.commonOptions));
  for (  Map.Entry<String,Map<String,String>> entry : this.worldsOptions.entrySet()) {
    allOptions.put(entry.getKey(),Collections.unmodifiableMap(entry.getValue()));
  }
  return Collections.unmodifiableMap(allOptions);
}

Fixed version (ground truth):
@Override public Map<String,Map<String,String>> getOptionsMap(){
  Map<String,Map<String,String>> allOptions=new HashMap<String,Map<String,String>>();
  if (this.commonOptions == null) {
    this.fetchPermissions();
  }
  allOptions.put(null,Collections.unmodifiableMap(this.commonOptions));
  for (  Map.Entry<String,Map<String,String>> entry : this.worldsOptions.entrySet()) {
    allOptions.put(entry.getKey(),Collections.unmodifiableMap(entry.getValue()));
  }
  return Collections.unmodifiableMap(allOptions);
}
Program: 151184
Project: 151184
Buggy source:
public ConfigurationSection getBackendConfig(String backend){
  return config.getConfigurationSection("String_Node_Str" + backend);
}

Fixed version (ground truth):
public ConfigurationSection getBackendConfig(String backend){
  ConfigurationSection section=config.getConfigurationSection("String_Node_Str" + backend);
  if (section == null) {
    section=config.createSection("String_Node_Str" + backend);
  }
  return section;
}
Program: 151185
Project: 151185
Buggy source:
@Command(name="String_Node_Str",syntax="String_Node_Str",permission="String_Node_Str",description="String_Node_Str") public void dumpData(Plugin plugin,CommandSender sender,Map<String,String> args){
  if (!(plugin instanceof PermissionsEx)) {
    return;
  }
  try {
    PermissionBackend backend=PermissionBackend.getBackend(args.get("String_Node_Str"),PermissionsEx.getPermissionManager(),plugin.getConfig(),null);
    backend.reload();
    backend.validate();
    PermissionsEx.getPermissionManager().getBackend().loadFrom(backend);
    sender.sendMessage(ChatColor.WHITE + "String_Node_Str" + args.get("String_Node_Str")+ "String_Node_Str");
  }
 catch (  RuntimeException e) {
    if (e.getCause() instanceof ClassNotFoundException) {
      sender.sendMessage(ChatColor.RED + "String_Node_Str");
    }
 else {
      sender.sendMessage(ChatColor.RED + "String_Node_Str" + e.getMessage());
      logger.severe("String_Node_Str" + e.getMessage());
      e.printStackTrace();
    }
  }
catch (  PermissionBackendException e) {
    sender.sendMessage(ChatColor.RED + "String_Node_Str" + args.get("String_Node_Str")+ "String_Node_Str");
    plugin.getLogger().log(Level.WARNING,"String_Node_Str",e);
  }
}

Fixed version (ground truth):
@Command(name="String_Node_Str",syntax="String_Node_Str",permission="String_Node_Str",description="String_Node_Str") public void dumpData(Plugin plugin,CommandSender sender,Map<String,String> args){
  if (!(plugin instanceof PermissionsEx)) {
    return;
  }
  try {
    PermissionManager mgr=PermissionsEx.getPermissionManager();
    PermissionBackend backend=mgr.createBackend(args.get("String_Node_Str"));
    mgr.getBackend().loadFrom(backend);
    sender.sendMessage(ChatColor.WHITE + "String_Node_Str" + args.get("String_Node_Str")+ "String_Node_Str");
  }
 catch (  RuntimeException e) {
    if (e.getCause() instanceof ClassNotFoundException) {
      sender.sendMessage(ChatColor.RED + "String_Node_Str");
    }
 else {
      sender.sendMessage(ChatColor.RED + "String_Node_Str" + e.getMessage());
      logger.severe("String_Node_Str" + e.getMessage());
      e.printStackTrace();
    }
  }
catch (  PermissionBackendException e) {
    sender.sendMessage(ChatColor.RED + "String_Node_Str" + args.get("String_Node_Str")+ "String_Node_Str");
    plugin.getLogger().log(Level.WARNING,"String_Node_Str",e);
  }
}
Program: 151186
Project: 151186
Buggy source:
public String getName(){
  return getOption("String_Node_Str",getIdentifier());
}

Fixed version (ground truth):
public String getName(){
  return getOption("String_Node_Str",null,getIdentifier());
}
Program: 151187
Project: 151187
Buggy source:
/** 
 * Set option for all worlds. Can be overwritten by world specific option
 * @param option Option name
 * @param value  Value to set, null to remove
 */
public void setOption(String option,String value){
  this.setOption(option,value,"String_Node_Str");
}

Fixed version (ground truth):
/** 
 * Set option for all worlds. Can be overwritten by world specific option
 * @param option Option name
 * @param value  Value to set, null to remove
 */
public void setOption(String option,String value){
  this.setOption(option,value,null);
}
Program: 151188
Project: 151188
Buggy source:
private PermissionUser getUser(String identifier,String fallbackName){
  PermissionUser user=users.get(identifier);
  if (user == null) {
    PermissionsUserData data=backend.getUserData(identifier);
    if (data != null) {
      if (fallbackName != null && !backend.hasUser(identifier) && backend.hasUser(fallbackName)) {
        if (isDebug()) {
          getLogger().info("String_Node_Str" + fallbackName + "String_Node_Str"+ identifier+ "String_Node_Str");
        }
        PermissionsUserData oldData=backend.getUserData(fallbackName);
        BackendDataTransfer.transferUser(oldData,data);
        oldData.remove();
      }
      data.setOption("String_Node_Str",null,fallbackName);
      user=new PermissionUser(identifier,data,this);
      user.initialize();
      this.users.put(identifier.toLowerCase(),user);
    }
 else {
      throw new IllegalStateException("String_Node_Str" + identifier + "String_Node_Str");
    }
  }
  return user;
}

Fixed version (ground truth):
private PermissionUser getUser(String identifier,String fallbackName){
  PermissionUser user=users.get(identifier);
  if (user == null) {
    PermissionsUserData data=backend.getUserData(identifier);
    if (data != null) {
      if (fallbackName != null && !backend.hasUser(identifier) && backend.hasUser(fallbackName)) {
        if (isDebug()) {
          getLogger().info("String_Node_Str" + fallbackName + "String_Node_Str"+ identifier+ "String_Node_Str");
        }
        PermissionsUserData oldData=backend.getUserData(fallbackName);
        BackendDataTransfer.transferUser(oldData,data);
        oldData.remove();
      }
      if (fallbackName != null) {
        data.setOption("String_Node_Str",fallbackName,null);
      }
      user=new PermissionUser(identifier,data,this);
      user.initialize();
      this.users.put(identifier.toLowerCase(),user);
    }
 else {
      throw new IllegalStateException("String_Node_Str" + identifier + "String_Node_Str");
    }
  }
  return user;
}
Program: 151189
Project: 151189
Buggy source:
/** 
 * Sets option value in specified world
 * @param option
 * @param worldName
 * @param value
 */
public void setOption(String option,String worldName,String value);

Fixed version (ground truth):
/** 
 * Sets option value in specified world
 * @param option
 * @param worldName
 * @param value
 */
public void setOption(String option,String value,String world);
Program: 151190
Project: 151190
Buggy source:
@Override public void setOption(String option,String worldName,String value){
  this.node.set(formatPath(worldName,"String_Node_Str",option),value);
  save();
}

Fixed version (ground truth):
@Override public void setOption(String option,String value,String worldName){
  this.node.set(formatPath(worldName,"String_Node_Str",option),value);
  save();
}
Program: 151191
Project: 151191
Buggy source:
@Override public void setOption(String option,String worldName,String value){
  if (option == null || option.isEmpty()) {
    return;
  }
  if (worldName == null) {
    worldName="String_Node_Str";
  }
  if (value == null || value.isEmpty()) {
    try {
      this.backend.getSQL().prepAndBind("String_Node_Str",this.getIdentifier(),option,this.type.ordinal(),worldName).execute();
    }
 catch (    SQLException e) {
      throw new RuntimeException(e);
    }
    if (!worldName.isEmpty() && this.worldsOptions.containsKey(worldName)) {
      this.worldsOptions.get(worldName).remove(option);
    }
 else {
      this.commonOptions.remove(option);
    }
    return;
  }
  Boolean newOption=true;
  if (this.commonOptions == null) {
    this.fetchPermissions();
  }
  if (!worldName.isEmpty() && worldsOptions.containsKey(worldName) && worldsOptions.get(worldName).containsKey(option)) {
    newOption=false;
  }
 else   if (worldName.isEmpty() && commonOptions.containsKey(option)) {
    newOption=false;
  }
  try {
    if (newOption) {
      this.backend.getSQL().prepAndBind("String_Node_Str",this.getIdentifier(),option,value,worldName,this.type.ordinal()).execute();
    }
 else {
      this.backend.getSQL().prepAndBind("String_Node_Str",value,this.getIdentifier(),this.type.ordinal(),option).execute();
    }
  }
 catch (  SQLException e) {
    throw new RuntimeException(e);
  }
  if (this.isVirtual()) {
    this.save();
  }
  this.fetchPermissions();
}

Fixed version (ground truth):
@Override public void setOption(String option,String value,String worldName){
  if (option == null || option.isEmpty()) {
    return;
  }
  if (worldName == null) {
    worldName="String_Node_Str";
  }
  if (value == null || value.isEmpty()) {
    try {
      this.backend.getSQL().prepAndBind("String_Node_Str",this.getIdentifier(),option,this.type.ordinal(),worldName).execute();
    }
 catch (    SQLException e) {
      throw new RuntimeException(e);
    }
    if (!worldName.isEmpty() && this.worldsOptions.containsKey(worldName)) {
      this.worldsOptions.get(worldName).remove(option);
    }
 else {
      this.commonOptions.remove(option);
    }
    return;
  }
  Boolean newOption=true;
  if (this.commonOptions == null) {
    this.fetchPermissions();
  }
  if (!worldName.isEmpty() && worldsOptions.containsKey(worldName) && worldsOptions.get(worldName).containsKey(option)) {
    newOption=false;
  }
 else   if (worldName.isEmpty() && commonOptions.containsKey(option)) {
    newOption=false;
  }
  try {
    if (newOption) {
      this.backend.getSQL().prepAndBind("String_Node_Str",this.getIdentifier(),option,value,worldName,this.type.ordinal()).execute();
    }
 else {
      this.backend.getSQL().prepAndBind("String_Node_Str",value,this.getIdentifier(),this.type.ordinal(),option).execute();
    }
  }
 catch (  SQLException e) {
    throw new RuntimeException(e);
  }
  if (this.isVirtual()) {
    this.save();
  }
  this.fetchPermissions();
}
Program: 151192
Project: 151192
Buggy source:
@EventHandler public void onPlayerLogin(PlayerLoginEvent event){
  try {
    if (!config.shouldLogPlayers()) {
      return;
    }
    PermissionUser user=getPermissionsManager().getUser(event.getPlayer());
    user.setOption("String_Node_Str",Long.toString(System.currentTimeMillis() / 1000L));
  }
 catch (  Throwable t) {
    ErrorReport.handleError("String_Node_Str",t);
  }
}

Fixed version (ground truth):
@EventHandler public void onPlayerLogin(PlayerLoginEvent event){
  try {
    PermissionUser user=getPermissionsManager().getUser(event.getPlayer());
    user.setOption("String_Node_Str",event.getPlayer().getName());
    if (!config.shouldLogPlayers()) {
      return;
    }
    user.setOption("String_Node_Str",Long.toString(System.currentTimeMillis() / 1000L));
  }
 catch (  Throwable t) {
    ErrorReport.handleError("String_Node_Str",t);
  }
}
Program: 151193
Project: 151193
Buggy source:
public String getName(){
  return getOption("String_Node_Str",null,getIdentifier());
}

Fixed version (ground truth):
public String getName(){
  return getOwnOption("String_Node_Str",null,getIdentifier());
}
Program: 151194
Project: 151194
Buggy source:
/** 
 * Set backend to specified backend. This would also cause backend resetting.
 * @param backendName name of backend to set to
 */
public void setBackend(String backendName) throws PermissionBackendException {
synchronized (this) {
    this.clearCache();
    this.backend=createBackend(backendName);
  }
  this.callEvent(PermissionSystemEvent.Action.BACKEND_CHANGED);
}

Fixed version (ground truth):
/** 
 * Set backend to specified backend. This would also cause backend resetting.
 * @param backendName name of backend to set to
 */
public void setBackend(String backendName) throws PermissionBackendException {
synchronized (this) {
    this.clearCache();
    this.backend=createBackend(backendName);
    this.preloadGroups();
  }
  this.callEvent(PermissionSystemEvent.Action.BACKEND_CHANGED);
}
Program: 151195
Project: 151195
Buggy source:
public PermissionManager(PermissionsEx plugin) throws PermissionBackendException {
  this.plugin=plugin;
  if (plugin.getConfiguration().useNetEvents()) {
    Plugin netEventsPlugin=plugin.getServer().getPluginManager().getPlugin("String_Node_Str");
    if (netEventsPlugin != null && netEventsPlugin.isEnabled()) {
      this.netEvents=(NetEventsPlugin)netEventsPlugin;
      plugin.getServer().getPluginManager().registerEvents(new RemoteEventListener(),plugin);
    }
  }
  this.initBackend();
  this.debugMode=plugin.getConfiguration().isDebug();
  this.allowOps=plugin.getConfiguration().allowOps();
  this.userAddGroupsLast=plugin.getConfiguration().userAddGroupsLast();
}

Fixed version (ground truth):
public PermissionManager(PermissionsEx plugin) throws PermissionBackendException {
  this.plugin=plugin;
  if (plugin.getConfiguration().useNetEvents()) {
    Plugin netEventsPlugin=plugin.getServer().getPluginManager().getPlugin("String_Node_Str");
    if (netEventsPlugin != null && netEventsPlugin.isEnabled()) {
      this.netEvents=(NetEventsPlugin)netEventsPlugin;
      plugin.getServer().getPluginManager().registerEvents(new RemoteEventListener(),plugin);
    }
  }
  this.debugMode=plugin.getConfiguration().isDebug();
  this.allowOps=plugin.getConfiguration().allowOps();
  this.userAddGroupsLast=plugin.getConfiguration().userAddGroupsLast();
  this.initBackend();
}
Program: 151196
Project: 151196
Buggy source:
/** 
 * Return object for specified group
 * @param groupname group's name
 * @return PermissionGroup object
 */
public PermissionGroup getGroup(String groupname){
  if (groupname == null || groupname.isEmpty()) {
    return null;
  }
  PermissionGroup group=groups.get(groupname.toLowerCase());
  if (group == null) {
    PermissionsGroupData data=this.backend.getGroupData(groupname);
    if (data != null) {
      group=new PermissionGroup(groupname,data,this);
      this.groups.put(groupname.toLowerCase(),group);
      try {
        group.initialize();
      }
 catch (      Exception e) {
        this.groups.remove(groupname.toLowerCase());
      }
    }
 else {
      throw new IllegalStateException("String_Node_Str" + groupname + "String_Node_Str");
    }
  }
  return group;
}

Fixed version (ground truth):
/** 
 * Return object for specified group
 * @param groupname group's name
 * @return PermissionGroup object
 */
public PermissionGroup getGroup(String groupname){
  if (groupname == null || groupname.isEmpty()) {
    return null;
  }
  PermissionGroup group=groups.get(groupname.toLowerCase());
  if (group == null) {
    PermissionsGroupData data=this.backend.getGroupData(groupname);
    if (data != null) {
      group=new PermissionGroup(groupname,data,this);
      this.groups.put(groupname.toLowerCase(),group);
      try {
        group.initialize();
      }
 catch (      Exception e) {
        this.groups.remove(groupname.toLowerCase());
        throw new IllegalStateException("String_Node_Str" + groupname,e);
      }
    }
 else {
      throw new IllegalStateException("String_Node_Str" + groupname + "String_Node_Str");
    }
  }
  return group;
}
Program: 151197
Project: 151197
Buggy source:
/** 
 * Load data from alternate backend. Assume that this overwrites all data in the receiving backend (except for users not included in transferring backend)
 * @param backend The backend to load data from
 */
public void loadFrom(PermissionBackend backend){
  for (  String user : backend.getUserIdentifiers()) {
    BackendDataTransfer.transferUser(backend.getUserData(user),getUserData(user));
  }
  for (  String group : backend.getGroupNames()) {
    BackendDataTransfer.transferGroup(backend.getGroupData(group),getGroupData(group));
  }
  for (  Map.Entry<String,List<String>> ent : backend.getAllWorldInheritance().entrySet()) {
    setWorldInheritance(ent.getKey(),ent.getValue());
  }
}

Fixed version (ground truth):
/** 
 * Load data from alternate backend. Assume that this overwrites all data in the receiving backend (except for users not included in transferring backend)
 * @param backend The backend to load data from
 */
public void loadFrom(PermissionBackend backend){
  for (  String group : backend.getGroupNames()) {
    BackendDataTransfer.transferGroup(backend.getGroupData(group),getGroupData(group));
  }
  for (  String user : backend.getUserIdentifiers()) {
    BackendDataTransfer.transferUser(backend.getUserData(user),getUserData(user));
  }
  for (  Map.Entry<String,List<String>> ent : backend.getAllWorldInheritance().entrySet()) {
    setWorldInheritance(ent.getKey(),ent.getValue());
  }
}
Program: 151198
Project: 151198
Buggy source:
@Override public void setPermissions(List<String> permissions,String worldName){
  if (worldName == null) {
    worldName="String_Node_Str";
  }
  try (SQLConnection conn=backend.getSQL()){
    conn.prepAndBind("String_Node_Str",this.getIdentifier(),this.type.ordinal(),worldName).execute();
    PreparedStatement statement=conn.prepAndBind("String_Node_Str",this.getIdentifier(),"String_Node_Str",worldName,this.type.ordinal());
    for (int i=permissions.size() - 1; i >= 0; i--) {
      statement.setString(2,permissions.get(i));
      statement.addBatch();
    }
    statement.executeBatch();
  }
 catch (  SQLException e) {
    throw new RuntimeException(e);
  }
  if (this.isVirtual()) {
    this.save();
  }
  if (this.commonPermissions == null) {
    this.fetchPermissions();
  }
 else {
    if (worldName.isEmpty()) {
      this.commonPermissions=new ArrayList<>(permissions);
    }
 else {
      this.worldsPermissions.put(worldName,new ArrayList<>(permissions));
    }
  }
}

Fixed version (ground truth):
@Override public void setPermissions(List<String> permissions,String worldName){
  if (worldName == null) {
    worldName="String_Node_Str";
  }
  try (SQLConnection conn=backend.getSQL()){
    conn.prepAndBind("String_Node_Str",this.getIdentifier(),this.type.ordinal(),worldName).execute();
    if (permissions.size() > 0) {
      Set<String> includedPerms=new HashSet<>();
      PreparedStatement statement=conn.prepAndBind("String_Node_Str",this.getIdentifier(),"String_Node_Str",worldName,this.type.ordinal());
      for (int i=permissions.size() - 1; i >= 0; i--) {
        if (!includedPerms.contains(permissions.get(i))) {
          statement.setString(2,permissions.get(i));
          statement.addBatch();
          includedPerms.add(permissions.get(i));
        }
      }
      statement.executeBatch();
    }
  }
 catch (  SQLException e) {
    throw new RuntimeException(e);
  }
  if (permissions.size() > 0 && this.isVirtual()) {
    this.save();
  }
  if (this.commonPermissions == null) {
    this.fetchPermissions();
  }
 else {
    if (worldName.isEmpty()) {
      this.commonPermissions=new ArrayList<>(permissions);
    }
 else {
      this.worldsPermissions.put(worldName,new ArrayList<>(permissions));
    }
  }
}
Program: 151199
Project: 151199
Buggy source:
/** 
 * Creates a backend but does not set it as the active backend. Useful for data transfer & such
 * @param backendName Name of the configuration section which describes this backend
 */
public PermissionBackend createBackend(String backendName) throws PermissionBackendException {
  ConfigurationSection config=plugin.getConfiguration().getBackendConfig(backendName);
  String backendType=config.getString("String_Node_Str");
  if (backendType == null) {
    config.set("String_Node_Str",backendType=backendName);
  }
  PermissionBackend backend=PermissionBackend.getBackend(backendType,this,config);
  return backend;
}

Fixed version (ground truth):
/** 
 * Creates a backend but does not set it as the active backend. Useful for data transfer & such
 * @param backendName Name of the configuration section which describes this backend
 */
public PermissionBackend createBackend(String backendName) throws PermissionBackendException {
  ConfigurationSection config=plugin.getConfiguration().getBackendConfig(backendName);
  String backendType=config.getString("String_Node_Str");
  if (backendType == null) {
    config.set("String_Node_Str",backendType=backendName);
  }
  return PermissionBackend.getBackend(backendType,this,config);
}
Program: 151200
Project: 151200
Buggy source:
public void resetUser(UUID uid){
  this.users.remove(uid.toString());
}

Fixed version (ground truth):
public void resetUser(Player ply){
  this.users.remove(ply.getUniqueId().toString());
  resetUser(ply.getName());
}
Program: 151201
Project: 151201
Buggy source:
@EventHandler(priority=EventPriority.LOWEST) public void onSystemEvent(PermissionSystemEvent event){
  if (isLocal(event)) {
    return;
  }
switch (event.getAction()) {
case BACKEND_CHANGED:
case DEBUGMODE_TOGGLE:
case REINJECT_PERMISSIBLES:
    return;
}
try {
  if (backend != null) {
    backend.close();
    backend.reload();
  }
  clearCache();
}
 catch (PermissionBackendException e) {
  e.printStackTrace();
}
}

Fixed version (ground truth):
@EventHandler(priority=EventPriority.LOWEST) public void onSystemEvent(PermissionSystemEvent event){
  if (isLocal(event)) {
    return;
  }
switch (event.getAction()) {
case BACKEND_CHANGED:
case DEBUGMODE_TOGGLE:
case REINJECT_PERMISSIBLES:
    return;
}
try {
  if (backend != null) {
    backend.reload();
  }
  clearCache();
}
 catch (PermissionBackendException e) {
  e.printStackTrace();
}
}
Program: 151202
Project: 151202
Buggy source:
/** 
 * Reset all in-memory groups and users, clean up runtime stuff, reloads backend
 */
public void reset() throws PermissionBackendException {
  this.clearCache();
  if (this.backend != null) {
    this.backend.close();
    initBackend();
  }
  this.callEvent(PermissionSystemEvent.Action.RELOADED);
}

Fixed version (ground truth):
/** 
 * Reset all in-memory groups and users, clean up runtime stuff, reloads backend
 */
public void reset() throws PermissionBackendException {
  this.clearCache();
  if (this.backend != null) {
    this.backend.reload();
  }
  this.callEvent(PermissionSystemEvent.Action.RELOADED);
}
Program: 151203
Project: 151203
Buggy source:
protected Pattern createPattern(String expression){
  try {
    return Pattern.compile(prepareRegexp(expression),Pattern.CASE_INSENSITIVE);
  }
 catch (  PatternSyntaxException e) {
    return Pattern.compile(Pattern.quote(expression),Pattern.CASE_INSENSITIVE);
  }
}

Fixed version (ground truth):
protected static Pattern createPattern(String expression){
  try {
    return Pattern.compile(prepareRegexp(expression),Pattern.CASE_INSENSITIVE);
  }
 catch (  PatternSyntaxException e) {
    return Pattern.compile(Pattern.quote(expression),Pattern.CASE_INSENSITIVE);
  }
}
Program: 151204
Project: 151204
Buggy source:
@Override public boolean isMatches(String expression,String permission){
  Pattern permissionMatcher=patternCache.get(expression);
  if (permissionMatcher == null) {
    patternCache.put(expression,permissionMatcher=createPattern(expression));
  }
  return permissionMatcher.matcher(permission).matches();
}

Fixed version (ground truth):
@Override public boolean isMatches(String expression,String permission){
  try {
    Pattern permissionMatcher=patternCache.get(expression);
    return permissionMatcher.matcher(permission).matches();
  }
 catch (  ExecutionException e) {
    return false;
  }
}
Program: 151205
Project: 151205
Buggy source:
private static void transferBase(PermissionsData from,PermissionsData to){
  for (  Map.Entry<String,List<String>> entry : from.getPermissionsMap().entrySet()) {
    to.setPermissions(new ArrayList<>(entry.getValue()),entry.getKey());
  }
  for (  Map.Entry<String,Map<String,String>> entry : from.getOptionsMap().entrySet()) {
    for (    Map.Entry<String,String> option : entry.getValue().entrySet()) {
      to.setOption(option.getKey(),option.getValue(),entry.getKey());
    }
  }
  List<String> globalParents=from.getParents(null);
  to.setParents(globalParents == null ? null : new ArrayList<>(globalParents),null);
  to.setPrefix(from.getPrefix(null),null);
  to.setSuffix(from.getSuffix(null),null);
  for (  String world : from.getWorlds()) {
    to.setPrefix(from.getPrefix(world),world);
    to.setSuffix(from.getSuffix(world),world);
    List<String> groups=from.getParents(world);
    if (groups == null || groups.isEmpty()) {
      continue;
    }
    to.setParents(new ArrayList<>(groups),world);
  }
}

Fixed version (ground truth):
private static void transferBase(PermissionsData from,PermissionsData to){
  for (  Map.Entry<String,List<String>> entry : from.getPermissionsMap().entrySet()) {
    to.setPermissions(entry.getValue(),entry.getKey());
  }
  for (  Map.Entry<String,Map<String,String>> entry : from.getOptionsMap().entrySet()) {
    for (    Map.Entry<String,String> option : entry.getValue().entrySet()) {
      to.setOption(option.getKey(),option.getValue(),entry.getKey());
    }
  }
  to.setParents(from.getParents(null),null);
  to.setPrefix(from.getPrefix(null),null);
  to.setSuffix(from.getSuffix(null),null);
  for (  String world : from.getWorlds()) {
    to.setPrefix(from.getPrefix(world),world);
    to.setSuffix(from.getSuffix(world),world);
    List<String> groups=from.getParents(world);
    if (groups == null || groups.isEmpty()) {
      continue;
    }
    to.setParents(groups,world);
  }
}
Program: 151206
Project: 151206
Buggy source:
@Override public boolean hasUser(String userName){
  return this.permissions.isConfigurationSection(buildPath("String_Node_Str",userName));
}

Fixed version (ground truth):
@Override public boolean hasUser(String userName){
  if (this.permissions.isConfigurationSection(buildPath("String_Node_Str",userName))) {
    return true;
  }
  ConfigurationSection userSection=this.permissions.getConfigurationSection("String_Node_Str");
  if (userSection != null) {
    for (    String name : userSection.getKeys(false)) {
      if (userName.equalsIgnoreCase(name)) {
        return true;
      }
    }
  }
  return false;
}
Program: 151207
Project: 151207
Buggy source:
@Override public boolean hasGroup(String group){
  return this.permissions.isConfigurationSection(buildPath("String_Node_Str",group));
}

Fixed version (ground truth):
@Override public boolean hasGroup(String group){
  if (this.permissions.isConfigurationSection(buildPath("String_Node_Str",group))) {
    return true;
  }
  ConfigurationSection userSection=this.permissions.getConfigurationSection("String_Node_Str");
  if (userSection != null) {
    for (    String name : userSection.getKeys(false)) {
      if (group.equalsIgnoreCase(name)) {
        return true;
      }
    }
  }
  return false;
}
Program: 151208
Project: 151208
Buggy source:
@Override public Map<String,List<String>> getPermissionsMap(){
  Map<String,List<String>> allPermissions=new HashMap<>();
  List<String> commonPermissions=this.node.getStringList("String_Node_Str");
  if (commonPermissions != null) {
    allPermissions.put(null,commonPermissions);
  }
  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);
      }
    }
  }
  return allPermissions;
}

Fixed version (ground truth):
@Override public Map<String,List<String>> getPermissionsMap(){
  Map<String,List<String>> allPermissions=new HashMap<>();
  List<String> commonPermissions=this.node.getStringList("String_Node_Str");
  if (commonPermissions != null) {
    allPermissions.put(null,Collections.unmodifiableList(commonPermissions));
  }
  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,Collections.unmodifiableList(worldPermissions));
      }
    }
  }
  return Collections.unmodifiableMap(allPermissions);
}
Program: 151209
Project: 151209
Buggy source:
/** 
 * Permissions
 */
@Override public List<String> getPermissions(String worldName){
  List<String> result=this.node.getStringList(formatPath(worldName,"String_Node_Str"));
  return result == null ? new LinkedList<String>() : result;
}

Fixed version (ground truth):
/** 
 * Permissions
 */
@Override public List<String> getPermissions(String worldName){
  List<String> result=this.node.getStringList(formatPath(worldName,"String_Node_Str"));
  return result == null ? Collections.<String>emptyList() : Collections.unmodifiableList(result);
}
Program: 151210
Project: 151210
Buggy source:
@Override public void setPermissions(List<String> permissions,String worldName){
  this.node.set(formatPath(worldName,"String_Node_Str"),permissions == null || permissions.isEmpty() ? null : permissions);
  save();
}

Fixed version (ground truth):
@Override public void setPermissions(List<String> permissions,String worldName){
  this.node.set(formatPath(worldName,"String_Node_Str"),permissions == null || permissions.isEmpty() ? null : new ArrayList<>(permissions));
  save();
}
Program: 151211
Project: 151211
Buggy source:
private Map<String,String> collectOptions(ConfigurationSection section){
  Map<String,String> options=new LinkedHashMap<>();
  for (  String key : section.getKeys(true)) {
    if (section.isConfigurationSection(key)) {
      continue;
    }
    options.put(key.replace(section.getRoot().options().pathSeparator(),'.'),section.getString(key));
  }
  return options;
}

Fixed version (ground truth):
private Map<String,String> collectOptions(ConfigurationSection section){
  Map<String,String> options=new LinkedHashMap<>();
  for (  String key : section.getKeys(true)) {
    if (section.isConfigurationSection(key)) {
      continue;
    }
    options.put(key.replace(section.getRoot().options().pathSeparator(),'.'),section.getString(key));
  }
  return Collections.unmodifiableMap(options);
}
Program: 151212
Project: 151212
Buggy source:
@Override public Set<String> getWorlds(){
  ConfigurationSection worldsSection=this.node.getConfigurationSection("String_Node_Str");
  if (worldsSection == null) {
    return new HashSet<>();
  }
  return worldsSection.getKeys(false);
}

Fixed version (ground truth):
@Override public Set<String> getWorlds(){
  ConfigurationSection worldsSection=this.node.getConfigurationSection("String_Node_Str");
  if (worldsSection == null) {
    return Collections.emptySet();
  }
  return Collections.unmodifiableSet(worldsSection.getKeys(false));
}
Program: 151213
Project: 151213
Buggy source:
@Override public void setParents(List<String> parents,String worldName){
  this.node.set(formatPath(worldName,parentPath),parents);
  save();
}

Fixed version (ground truth):
@Override public void setParents(List<String> parents,String worldName){
  this.node.set(formatPath(worldName,parentPath),parents == null ? null : new ArrayList<>(parents));
  save();
}
Program: 151214
Project: 151214
Buggy source:
@Override public Map<String,Map<String,String>> getOptionsMap(){
  Map<String,Map<String,String>> allOptions=new HashMap<>();
  allOptions.put(null,this.getOptions(null));
  for (  String worldName : this.getWorlds()) {
    allOptions.put(worldName,this.getOptions(worldName));
  }
  return allOptions;
}

Fixed version (ground truth):
@Override public Map<String,Map<String,String>> getOptionsMap(){
  Map<String,Map<String,String>> allOptions=new HashMap<>();
  allOptions.put(null,this.getOptions(null));
  for (  String worldName : this.getWorlds()) {
    allOptions.put(worldName,this.getOptions(worldName));
  }
  return Collections.unmodifiableMap(allOptions);
}
Program: 151215
Project: 151215
Buggy source:
@Override public Map<String,String> getOptions(String worldName){
  ConfigurationSection optionsSection=this.node.getConfigurationSection(formatPath(worldName,"String_Node_Str"));
  if (optionsSection == null) {
    return new HashMap<>(0);
  }
  return collectOptions(optionsSection);
}

Fixed version (ground truth):
@Override public Map<String,String> getOptions(String worldName){
  ConfigurationSection optionsSection=this.node.getConfigurationSection(formatPath(worldName,"String_Node_Str"));
  if (optionsSection == null) {
    return Collections.emptyMap();
  }
  return collectOptions(optionsSection);
}
Program: 151216
Project: 151216
Buggy source:
@Override public boolean hasUser(String userName){
  try {
    ResultSet res=getSQL().prepAndBind("String_Node_Str",SQLData.Type.USER.ordinal(),userName).executeQuery();
    return res.next();
  }
 catch (  SQLException e) {
    return false;
  }
}

Fixed version (ground truth):
@Override public boolean hasUser(String userName){
  try (SQLConnection conn=getSQL()){
    ResultSet res=conn.prepAndBind("String_Node_Str",SQLData.Type.USER.ordinal(),userName).executeQuery();
    return res.next();
  }
 catch (  SQLException e) {
    return false;
  }
}
Program: 151217
Project: 151217
Buggy source:
@EventHandler public void onPlayerQuit(PlayerQuitEvent event){
  try {
    if (config.shouldLogPlayers()) {
      getPermissionsManager().getUser(event.getPlayer()).setOption("String_Node_Str",Long.toString(System.currentTimeMillis() / 1000L));
    }
    getPermissionsManager().resetUser(event.getPlayer().getUniqueId());
  }
 catch (  Throwable t) {
    ErrorReport.handleError("String_Node_Str",t);
  }
}

Fixed version (ground truth):
@EventHandler public void onPlayerQuit(PlayerQuitEvent event){
  try {
    if (config.shouldLogPlayers()) {
      getPermissionsManager().getUser(event.getPlayer()).setOption("String_Node_Str",Long.toString(System.currentTimeMillis() / 1000L));
    }
    getPermissionsManager().resetUser(event.getPlayer());
  }
 catch (  Throwable t) {
    ErrorReport.handleError("String_Node_Str",t);
  }
}
Program: 151218
Project: 151218
Buggy source:
@EventHandler public void onPlayerLogin(PlayerLoginEvent event){
  try {
    PermissionUser user=getPermissionsManager().getUser(event.getPlayer());
    user.setOption("String_Node_Str",event.getPlayer().getName());
    if (!config.shouldLogPlayers()) {
      return;
    }
    user.setOption("String_Node_Str",Long.toString(System.currentTimeMillis() / 1000L));
  }
 catch (  Throwable t) {
    ErrorReport.handleError("String_Node_Str",t);
  }
}

Fixed version (ground truth):
@EventHandler public void onPlayerLogin(PlayerLoginEvent event){
  try {
    PermissionUser user=getPermissionsManager().getUser(event.getPlayer());
    if (!user.isVirtual()) {
      user.setOption("String_Node_Str",event.getPlayer().getName());
    }
    if (!config.shouldLogPlayers()) {
      return;
    }
    user.setOption("String_Node_Str",Long.toString(System.currentTimeMillis() / 1000L));
  }
 catch (  Throwable t) {
    ErrorReport.handleError("String_Node_Str",t);
  }
}
Program: 151219
Project: 151219
Buggy source:
private void updateSelective(PermissionEntityEvent event,PermissionUser user){
  final Player p=plugin.getServer().getPlayer(UUID.fromString(user.getIdentifier()));
  if (p != null) {
switch (event.getAction()) {
case SAVED:
      break;
case PERMISSIONS_CHANGED:
case TIMEDPERMISSION_EXPIRED:
    updatePlayerPermission(getCreateWrapper(p,"String_Node_Str"),p,user,p.getWorld().getName());
  p.recalculatePermissions();
break;
case OPTIONS_CHANGED:
case INFO_CHANGED:
updatePlayerMetadata(getCreateWrapper(p,"String_Node_Str"),user,p.getWorld().getName());
p.recalculatePermissions();
break;
default :
updateAttachment(p);
}
}
}

Fixed version (ground truth):
private void updateSelective(PermissionEntityEvent event,PermissionUser user){
  final Player p=user.getPlayer();
  if (p != null) {
switch (event.getAction()) {
case SAVED:
      break;
case PERMISSIONS_CHANGED:
case TIMEDPERMISSION_EXPIRED:
    updatePlayerPermission(getCreateWrapper(p,"String_Node_Str"),p,user,p.getWorld().getName());
  p.recalculatePermissions();
break;
case OPTIONS_CHANGED:
case INFO_CHANGED:
updatePlayerMetadata(getCreateWrapper(p,"String_Node_Str"),user,p.getWorld().getName());
p.recalculatePermissions();
break;
default :
updateAttachment(p);
}
}
}
Program: 151220
Project: 151220
Buggy source:
/** 
 * User permission management
 */
@Command(name="String_Node_Str",syntax="String_Node_Str",permission="String_Node_Str",description="String_Node_Str") public void userListAliasPermissions(PermissionsEx plugin,CommandSender sender,Map<String,String> args){
  String userName=this.autoCompletePlayerName(args.get("String_Node_Str"));
  String worldName=this.autoCompleteWorldName(args.get("String_Node_Str"));
  PermissionUser user=plugin.getPermissionsManager().getUser(userName);
  if (user == null) {
    sender.sendMessage(ChatColor.RED + "String_Node_Str");
    return;
  }
  userName=user.getName();
  sender.sendMessage("String_Node_Str" + user.getIdentifier() + '/'+ userName+ "String_Node_Str");
  printEntityInheritance(sender,user.getParents());
  Map<String,List<PermissionGroup>> allParents=user.getAllParents();
  for (  String world : allParents.keySet()) {
    if (world == null) {
      continue;
    }
    sender.sendMessage("String_Node_Str" + world + "String_Node_Str");
    printEntityInheritance(sender,allParents.get(world));
  }
  sender.sendMessage(userName + "String_Node_Str");
  this.sendMessage(sender,this.mapPermissions(worldName,user,0));
  sender.sendMessage(userName + "String_Node_Str");
  for (  Map.Entry<String,String> option : user.getOptions(worldName).entrySet()) {
    sender.sendMessage("String_Node_Str" + option.getKey() + "String_Node_Str"+ option.getValue()+ "String_Node_Str");
  }
}

Fixed version (ground truth):
/** 
 * User permission management
 */
@Command(name="String_Node_Str",syntax="String_Node_Str",permission="String_Node_Str",description="String_Node_Str") public void userListAliasPermissions(PermissionsEx plugin,CommandSender sender,Map<String,String> args){
  String userName=this.autoCompletePlayerName(args.get("String_Node_Str"));
  String worldName=this.autoCompleteWorldName(args.get("String_Node_Str"));
  PermissionUser user=plugin.getPermissionsManager().getUser(userName);
  if (user == null) {
    sender.sendMessage(ChatColor.RED + "String_Node_Str");
    return;
  }
  userName=user.getName();
  sender.sendMessage("String_Node_Str" + describeUser(user) + "String_Node_Str");
  printEntityInheritance(sender,user.getParents());
  Map<String,List<PermissionGroup>> allParents=user.getAllParents();
  for (  String world : allParents.keySet()) {
    if (world == null) {
      continue;
    }
    sender.sendMessage("String_Node_Str" + world + "String_Node_Str");
    printEntityInheritance(sender,allParents.get(world));
  }
  sender.sendMessage(userName + "String_Node_Str");
  this.sendMessage(sender,this.mapPermissions(worldName,user,0));
  sender.sendMessage(userName + "String_Node_Str");
  for (  Map.Entry<String,String> option : user.getOptions(worldName).entrySet()) {
    sender.sendMessage("String_Node_Str" + option.getKey() + "String_Node_Str"+ option.getValue()+ "String_Node_Str");
  }
}
Program: 151221
Project: 151221
Buggy source:
private void uninjectPermissible(Player player){
  try {
    boolean success=false;
    for (    PermissibleInjector injector : injectors) {
      if (injector.isApplicable(player)) {
        Permissible pexPerm=injector.getPermissible(player);
        if (pexPerm instanceof PermissiblePEX) {
          if (injector.inject(player,((PermissiblePEX)pexPerm).getPreviousPermissible()) != null) {
            success=true;
            break;
          }
        }
      }
    }
    if (!success) {
      plugin.getLogger().warning("String_Node_Str" + player.getName() + "String_Node_Str");
    }
 else     if (hasDebugMode()) {
      plugin.getLogger().info("String_Node_Str" + player.getName() + "String_Node_Str");
    }
  }
 catch (  Throwable e) {
    e.printStackTrace();
  }
}

Fixed version (ground truth):
private void uninjectPermissible(Player player){
  try {
    boolean success=false;
    for (    PermissibleInjector injector : injectors) {
      if (injector.isApplicable(player)) {
        Permissible pexPerm=injector.getPermissible(player);
        if (pexPerm instanceof PermissiblePEX) {
          if (injector.inject(player,((PermissiblePEX)pexPerm).getPreviousPermissible()) != null) {
            success=true;
            break;
          }
        }
 else {
          success=true;
          break;
        }
      }
    }
    if (!success) {
      plugin.getLogger().warning("String_Node_Str" + player.getName() + "String_Node_Str");
    }
 else     if (hasDebugMode()) {
      plugin.getLogger().info("String_Node_Str" + player.getName() + "String_Node_Str");
    }
  }
 catch (  Throwable e) {
    e.printStackTrace();
  }
}
Program: 151222
Project: 151222
Buggy source:
public Map<String,List<PermissionGroup>> getAllGroups(){
  Map<String,List<PermissionGroup>> allGroups=new HashMap<String,List<PermissionGroup>>();
  for (  String worldName : this.getWorlds()) {
    allGroups.put(worldName,this.getWorldGroups(worldName));
  }
  allGroups.put(null,this.getWorldGroups(null));
  return allGroups;
}

Fixed version (ground truth):
@Deprecated public Map<String,List<PermissionGroup>> getAllGroups(){
  return getAllParents();
}
Program: 151223
Project: 151223
Buggy source:
/** 
 * Performs a traversal of permissions hierarchy Ordering: For each entity (traversed depth-first): <ol> <li>Chosen world</li> <li>World inheritance for chosen world</li> <li>Global scope</li> </ol>
 * @return a value if any found
 */
public Return traverse(){
  LinkedList<PermissionEntity> entities=new LinkedList<PermissionEntity>();
  Set<PermissionEntity> visited=new HashSet<PermissionEntity>();
  entities.add(start);
  Return ret=null;
  while (!entities.isEmpty()) {
    PermissionEntity current=entities.removeFirst();
    if (visited.contains(current)) {
      if (current.isDebug()) {
        current.manager.getLogger().warning("String_Node_Str" + current.getIdentifier() + "String_Node_Str"+ start+ "String_Node_Str");
      }
      continue;
    }
    visited.add(current);
    if (world != null) {
      ret=fetchLocal(current,world);
      if (ret != null) {
        break;
      }
      ret=traverseWorldInheritance(current);
      if (ret != null) {
        break;
      }
    }
    ret=fetchLocal(current,null);
    if (ret != null) {
      break;
    }
    if (traverseInheritance) {
      List<PermissionGroup> parents=current.getParents(world);
      for (int i=parents.size() - 1; i >= 0; --i) {
        entities.addFirst(parents.get(i));
      }
    }
  }
  return ret;
}

Fixed version (ground truth):
/** 
 * Performs a traversal of permissions hierarchy Ordering: For each entity (traversed depth-first): <ol> <li>Chosen world</li> <li>World inheritance for chosen world</li> <li>Global scope</li> </ol>
 * @return a value if any found
 */
public Return traverse(){
  LinkedList<PermissionEntity> entities=new LinkedList<>();
  Set<PermissionEntity> visited=new HashSet<>();
  entities.add(start);
  Return ret=null;
  while (!entities.isEmpty()) {
    PermissionEntity current=entities.removeFirst();
    if (visited.contains(current)) {
      if (current.isDebug()) {
        current.manager.getLogger().warning("String_Node_Str" + current.getIdentifier() + "String_Node_Str"+ start+ "String_Node_Str");
      }
      continue;
    }
    visited.add(current);
    if (world != null) {
      ret=fetchLocal(current,world);
      if (ret != null) {
        break;
      }
      ret=traverseWorldInheritance(current);
      if (ret != null) {
        break;
      }
    }
    ret=fetchLocal(current,null);
    if (ret != null) {
      break;
    }
    if (traverseInheritance) {
      List<PermissionGroup> parents=current.getParents(world);
      for (int i=parents.size() - 1; i >= 0; --i) {
        entities.addFirst(parents.get(i));
      }
    }
  }
  return ret;
}