Program: 87055
Project: 87055
Buggy source:
/** 
 * Edit access rule handler.
 */
private void editAccessRule(){
  if (getAccessRulesPane().getAccessRulesTable().getSelectedRowCount() < 1) {
    displayWarning(ResourceUtil.getString("String_Node_Str"));
  }
 else {
    try {
      DefaultMutableTreeNode node=(DefaultMutableTreeNode)getAccessRulesPane().getAccessRulesTree().getLastSelectedPathComponent();
      if (node == null) {
        return;
      }
      JTable accessRulesTable=getAccessRulesPane().getAccessRulesTable();
      Object userObject=node.getUserObject();
      DefaultTableModel tableModel=(DefaultTableModel)accessRulesTable.getModel();
      int selectedRow=accessRulesTable.convertRowIndexToModel(accessRulesTable.getSelectedRow());
      AccessRule accessRule=null;
      if (userObject instanceof Repository) {
        Repository repository=(Repository)userObject;
        Path path=(Path)tableModel.getValueAt(selectedRow,0);
        Object object=tableModel.getValueAt(selectedRow,1);
        if (object instanceof Group) {
          accessRule=Document.findGroupAccessRule(repository,path.getPath(),(Group)object);
        }
 else         if (object instanceof User) {
          accessRule=Document.findUserAccessRule(repository,path.getPath(),(User)object);
        }
      }
 else       if (userObject instanceof Path) {
        Path path=(Path)userObject;
        Object object=tableModel.getValueAt(selectedRow,0);
        if (object instanceof Group) {
          accessRule=Document.findGroupAccessRule(path.getRepository(),path.getPath(),(Group)object);
        }
 else         if (object instanceof User) {
          accessRule=Document.findUserAccessRule(path.getRepository(),path.getPath(),(User)object);
        }
      }
 else {
        Repository repository=(Repository)tableModel.getValueAt(selectedRow,0);
        Path path=(Path)tableModel.getValueAt(selectedRow,1);
        Object object=tableModel.getValueAt(selectedRow,2);
        if (object instanceof Group) {
          accessRule=Document.findGroupAccessRule(repository,path.getPath(),(Group)object);
        }
 else         if (object instanceof User) {
          accessRule=Document.findUserAccessRule(repository,path.getPath(),(User)object);
        }
      }
      Message message=new Message();
      JDialog dialog=new EditAccessRuleDialog(accessRule,message);
      DialogUtil.center(this,dialog);
      dialog.setVisible(true);
      if (message.getState() == Message.SUCCESS) {
        Document.setUnsavedChanges();
        refreshUserDetails();
        refreshGroupDetails();
        refreshAccessRuleTree(null);
      }
    }
 catch (    ApplicationException ae) {
      displayError(ResourceUtil.getString("String_Node_Str"));
    }
  }
  updateTitle();
}

Fixed version (ground truth):
/** 
 * Edit access rule handler.
 */
private void editAccessRule(){
  if (getAccessRulesPane().getAccessRulesTable().getSelectedRowCount() < 1) {
    displayWarning(ResourceUtil.getString("String_Node_Str"));
  }
 else {
    try {
      DefaultMutableTreeNode node=(DefaultMutableTreeNode)getAccessRulesPane().getAccessRulesTree().getLastSelectedPathComponent();
      if (node == null) {
        return;
      }
      JTable accessRulesTable=getAccessRulesPane().getAccessRulesTable();
      Object userObject=node.getUserObject();
      DefaultTableModel tableModel=(DefaultTableModel)accessRulesTable.getModel();
      int selectedRow=accessRulesTable.convertRowIndexToModel(accessRulesTable.getSelectedRow());
      AccessRule accessRule=null;
      if (userObject instanceof Repository) {
        Repository repository=(Repository)userObject;
        Path path=(Path)tableModel.getValueAt(selectedRow,0);
        Object object=tableModel.getValueAt(selectedRow,1);
        if (object instanceof Group) {
          accessRule=Document.findGroupAccessRule(repository,path.getPath(),(Group)object);
        }
 else         if (object instanceof User) {
          accessRule=Document.findUserAccessRule(repository,path.getPath(),(User)object);
        }
      }
 else       if (userObject instanceof Path) {
        Path path=(Path)userObject;
        Object object=tableModel.getValueAt(selectedRow,0);
        if (object instanceof Group) {
          accessRule=Document.findGroupAccessRule(path.getRepository(),path.getPath(),(Group)object);
        }
 else         if (object instanceof User) {
          accessRule=Document.findUserAccessRule(path.getRepository(),path.getPath(),(User)object);
        }
      }
 else {
        Repository repository=(Repository)tableModel.getValueAt(selectedRow,0);
        Path path=(Path)tableModel.getValueAt(selectedRow,1);
        Object object=tableModel.getValueAt(selectedRow,2);
        if (object instanceof Group) {
          accessRule=Document.findGroupAccessRule(repository,path.getPath(),(Group)object);
        }
 else         if (object instanceof User) {
          accessRule=Document.findUserAccessRule(repository,path.getPath(),(User)object);
        }
      }
      if (accessRule == null) {
        displayError(ResourceUtil.getString("String_Node_Str"));
      }
 else {
        Message message=new Message();
        Path path=accessRule.getPath();
        JDialog dialog=new EditAccessRuleDialog(accessRule,message);
        DialogUtil.center(this,dialog);
        dialog.setVisible(true);
        if (message.getState() == Message.SUCCESS) {
          Document.setUnsavedChanges();
          refreshUserDetails();
          refreshGroupDetails();
          if (accessRule.getPath().equals(path)) {
            refreshAccessRuleTree(path);
          }
 else {
            refreshAccessRuleTree(null);
          }
        }
      }
    }
 catch (    ApplicationException ae) {
      displayError(ResourceUtil.getString("String_Node_Str"));
    }
  }
  updateTitle();
}