nus-yam/ex-repair huggingface dataset:
Program: 145764
Project: 145764
Buggy source:
public static synchronized void removeCurrentUser(HttpSession session){
  if (null == currentUsers) {
    return;
  }
  if (currentUsers.getMap().containsKey(session)) {
    User user=(User)currentUsers.getMap().get(session);
    AuthenticationService service=(AuthenticationService)Components.getComponent(AuthenticationService.class);
    if (service.isAuthenticated(user)) {
      Logger.debug("String_Node_Str" + user.getLogin());
      user.setLastLogout(user.getLastAccess());
      UserManagerFactory.getInstance().systemStore(user);
    }
    currentUsers.getMap().remove(session);
  }
}

Fixed version (ground truth):
public static synchronized void removeCurrentUser(HttpSession session){
  if (null == currentUsers) {
    return;
  }
  if (currentUsers.getMap().containsKey(session)) {
    User user=(User)currentUsers.getMap().get(session);
    AuthenticationService service=(AuthenticationService)Components.getComponent(AuthenticationService.class);
    if (service.isAuthenticated(user)) {
      Logger.debug("String_Node_Str" + user.getLogin());
      user.setLastLogout(user.getLastAccess());
      Application.get().storeObject(Application.OID,user.getApplication());
      UserManagerFactory.getInstance().systemStore(user);
    }
    currentUsers.getMap().remove(session);
  }
}
Program: 145766
Project: 145766
Buggy source:
public void doPost(HttpServletRequest request,HttpServletResponse response) throws ServletException, IOException {
  String name=request.getParameter("String_Node_Str");
  SnipSpace space=SnipSpaceFactory.getInstance();
  Snip snip=space.load(name);
  String content=request.getParameter("String_Node_Str");
  if (request.getParameter("String_Node_Str") != null) {
    request.setAttribute("String_Node_Str",SnipFormatter.toXML(snip,content));
    RequestDispatcher dispatcher=request.getRequestDispatcher("String_Node_Str");
    dispatcher.forward(request,response);
    return;
  }
 else   if (request.getParameter("String_Node_Str") == null) {
    HttpSession session=request.getSession();
    if (session != null) {
      User user=Application.get().getUser();
      AuthenticationService service=(AuthenticationService)Components.getComponent(AuthenticationService.class);
      if (service.isAuthenticated(user)) {
        if (snip != null) {
          snip.setContent(content);
          space.store(snip);
        }
 else {
          snip=space.create(name,content);
        }
      }
 else {
        response.sendError(HttpServletResponse.SC_FORBIDDEN);
      }
    }
  }
 else   if (snip == null) {
    response.sendRedirect(request.getParameter("String_Node_Str"));
    return;
  }
  Configuration config=Application.get().getConfiguration();
  response.sendRedirect(config.getUrl("String_Node_Str" + SnipLink.encode(name)));
}

Fixed version (ground truth):
public void doPost(HttpServletRequest request,HttpServletResponse response) throws ServletException, IOException {
  String name=request.getParameter("String_Node_Str");
  SnipSpace space=SnipSpaceFactory.getInstance();
  Snip snip=space.load(name);
  String content=request.getParameter("String_Node_Str");
  if (request.getParameter("String_Node_Str") != null) {
    request.setAttribute("String_Node_Str",SnipFormatter.toXML(snip,content));
    RequestDispatcher dispatcher=request.getRequestDispatcher("String_Node_Str");
    dispatcher.forward(request,response);
    return;
  }
 else   if (request.getParameter("String_Node_Str") == null) {
    HttpSession session=request.getSession();
    if (session != null) {
      User user=Application.get().getUser();
      AuthenticationService service=(AuthenticationService)Components.getComponent(AuthenticationService.class);
      if (service.isAuthenticated(user) && (null == snip || Security.checkPermission(Permissions.EDIT_SNIP,user,snip))) {
        if (snip != null) {
          snip.setContent(content);
          space.store(snip);
        }
 else {
          snip=space.create(name,content);
        }
      }
 else {
        response.sendError(HttpServletResponse.SC_FORBIDDEN);
      }
    }
  }
 else   if (snip == null) {
    response.sendRedirect(request.getParameter("String_Node_Str"));
    return;
  }
  Configuration config=Application.get().getConfiguration();
  response.sendRedirect(config.getUrl("String_Node_Str" + SnipLink.encode(name)));
}
Program: 145768
Project: 145768
Buggy source:
public List getPosts(int count){
  Calendar startC=new GregorianCalendar();
  startC.setTime(new java.util.Date());
  Calendar endC=(Calendar)startC.clone();
  endC.add(Calendar.DAY_OF_MONTH,count - 1);
  String start=name + "String_Node_Str" + Month.toKey(startC)+ "String_Node_Str";
  String end=name + "String_Node_Str" + Month.toKey(endC)+ "String_Node_Str";
  List posts=Arrays.asList(space.match(start,end));
  return posts;
}

Fixed version (ground truth):
public List getPosts(int count){
  Calendar startC=new GregorianCalendar();
  startC.setTime(new java.util.Date());
  Calendar endC=(Calendar)startC.clone();
  endC.add(Calendar.DAY_OF_MONTH,count - 1);
  String start=name + "String_Node_Str" + Month.toKey(startC)+ "String_Node_Str";
  String end=name + "String_Node_Str" + Month.toKey(endC)+ "String_Node_Str";
  List posts=new ArrayList();
  posts.addAll(Arrays.asList(space.match(start,end)));
  if (name.equals(startName)) {
    posts.addAll(space.getByDate(Month.toKey(startC),Month.toKey(endC)));
  }
  return posts;
}
Program: 145769
Project: 145769
Buggy source:
public BlogImpl(SnipSpace space,String blogName){
  this.space=space;
  if (blogName == null || "String_Node_Str".equals(blogName)) {
    blogName=Application.get().getConfiguration().getStartSnip();
  }
  this.name=blogName;
  this.blog=space.load(name);
}

Fixed version (ground truth):
public BlogImpl(SnipSpace space,String blogName){
  this.space=space;
  this.startName=Application.get().getConfiguration().getStartSnip();
  if (blogName == null || "String_Node_Str".equals(blogName)) {
    blogName=startName;
  }
  this.name=blogName;
  this.blog=space.load(name);
}
Program: 145770
Project: 145770
Buggy source:
public Collection getLabels(String type){
  ArrayList labels=new ArrayList();
  if (null == type) {
    return labels;
  }
  Iterator iterator=this.labels.values().iterator();
  while (iterator.hasNext()) {
    Label label=(Label)iterator.next();
    if (type.equals(label.getType())) {
      labels.add(label);
    }
  }
  return labels;
}

Fixed version (ground truth):
public Collection getLabels(String type){
  ArrayList result=new ArrayList();
  if (null == type) {
    return result;
  }
  Iterator iterator=this.labels.values().iterator();
  while (iterator.hasNext()) {
    Label label=(Label)iterator.next();
    if (null != label && type.equals(label.getType())) {
      result.add(label);
    }
  }
  return result;
}
Program: 145771
Project: 145771
Buggy source:
public List getPosts(int count){
  Calendar startC=new GregorianCalendar();
  startC.setTime(new java.util.Date());
  Calendar endC=(Calendar)startC.clone();
  endC.add(Calendar.DAY_OF_MONTH,count - 1);
  String start=name + "String_Node_Str" + Month.toKey(startC)+ "String_Node_Str";
  String end=name + "String_Node_Str" + Month.toKey(endC)+ "String_Node_Str";
  List posts=new ArrayList();
  posts.addAll(Arrays.asList(space.match(start,end)));
  if (name.equals(startName)) {
    posts.addAll(space.getByDate(Month.toKey(startC),Month.toKey(endC)));
  }
  return posts;
}

Fixed version (ground truth):
public List getPosts(int count){
  Calendar startC=new GregorianCalendar();
  startC.setTime(new java.util.Date());
  Calendar endC=(Calendar)startC.clone();
  endC.add(Calendar.DAY_OF_MONTH,count - 1);
  String start=name + "String_Node_Str" + Month.toKey(startC)+ "String_Node_Str";
  String end=name + "String_Node_Str" + Month.toKey(endC)+ "String_Node_Str";
  List posts=new ArrayList();
  posts.addAll(Arrays.asList(space.match(start,end)));
  Collections.sort(posts,comparator);
  if (name.equals(startName)) {
    posts.addAll(space.getByDate(Month.toKey(startC),Month.toKey(endC)));
  }
  return posts;
}
Program: 145772
Project: 145772
Buggy source:
public static Test suite(){
  TestSuite s=new TestSuite();
  s.addTestSuite(NoneNameFormatterTest.class);
  s.addTestSuite(CapitalizeNameFormatterTest.class);
  s.addTestSuite(PathRemoveNameFormatterTest.class);
  return s;
}

Fixed version (ground truth):
public static Test suite(){
  TestSuite s=new TestSuite();
  s.addTestSuite(NoneNameFormatterTest.class);
  s.addTestSuite(CapitalizeNameFormatterTest.class);
  s.addTestSuite(PathRemoveNameFormatterTest.class);
  s.addTestSuite(PostNameComparatorTest.class);
  return s;
}
Program: 145773
Project: 145773
Buggy source:
private void deserialize(String labelString){
  labels=new HashMap();
  if ("String_Node_Str".equals(labelString)) {
    return;
  }
  StringTokenizer tokenizer=new StringTokenizer(labelString,"String_Node_Str");
  while (tokenizer.hasMoreTokens()) {
    String labelToken=tokenizer.nextToken();
    String[] data=StringUtil.split(labelToken,"String_Node_Str");
    Label label=createLabel(data[0],data[1],data[2]);
    labels.put(label.getName(),label);
  }
  return;
}

Fixed version (ground truth):
private void deserialize(String labelString){
  labels=new HashMap();
  if ("String_Node_Str".equals(labelString)) {
    return;
  }
  StringTokenizer tokenizer=new StringTokenizer(labelString,"String_Node_Str");
  while (tokenizer.hasMoreTokens()) {
    String labelToken=tokenizer.nextToken();
    String[] data=StringUtil.split(labelToken,"String_Node_Str");
    if (data.length == 3) {
      Label label=createLabel(data[0],data[1],data[2]);
      labels.put(label.getName(),label);
    }
 else {
      System.err.println("String_Node_Str" + labelToken + "String_Node_Str");
    }
  }
  return;
}
Program: 145775
Project: 145775
Buggy source:
private String replaceTokens(String value){
  int idx=value.indexOf("String_Node_Str");
  if (idx != -1) {
    StringBuffer replaced=new StringBuffer();
    if (idx > 0) {
      replaced.append(value.substring(0,idx));
    }
    replaced.append(getConfDir().getPath());
    int endIdx=idx + "String_Node_Str".length();
    if (endIdx < value.length()) {
      replaced.append(value.substring(endIdx));
    }
    return replaced.toString();
  }
  return value;
}

Fixed version (ground truth):
private String replaceTokens(String value){
  if (value != null) {
    int idx=value.indexOf("String_Node_Str");
    if (idx != -1) {
      StringBuffer replaced=new StringBuffer();
      if (idx > 0) {
        replaced.append(value.substring(0,idx));
      }
      replaced.append(getConfDir().getPath());
      int endIdx=idx + "String_Node_Str".length();
      if (endIdx < value.length()) {
        replaced.append(value.substring(endIdx));
      }
      return replaced.toString();
    }
  }
  return value;
}
Program: 145776
Project: 145776
Buggy source:
protected static void initClassPath(String extraClassPath){
  try {
    URL location=Launcher.class.getProtectionDomain().getCodeSource().getLocation();
    JarInputStream jarInputStream=new JarInputStream(location.openStream());
    Manifest manifest=jarInputStream.getManifest();
    Attributes mainAttributes=manifest.getMainAttributes();
    String manifestClassPath=mainAttributes.getValue("String_Node_Str");
    if (extraClassPath != null && extraClassPath.length() > 0) {
      manifestClassPath+="String_Node_Str" + extraClassPath.replace(':',' ');
    }
    File directoryBase=new File(location.getFile()).getParentFile();
    StringBuffer classPath=new StringBuffer(location.getFile());
    StringTokenizer tokenizer=new StringTokenizer(manifestClassPath,"String_Node_Str" + File.pathSeparatorChar,false);
    while (tokenizer.hasMoreTokens()) {
      classPath.append(File.pathSeparatorChar);
      String file=tokenizer.nextToken();
      classPath.append(new File(directoryBase,file).getCanonicalPath());
    }
    System.setProperty("String_Node_Str",classPath.toString());
    System.err.println("String_Node_Str" + classPath.toString());
  }
 catch (  IOException e) {
    System.err.println("String_Node_Str");
  }
}

Fixed version (ground truth):
protected static void initClassPath(String extraClassPath){
  try {
    URL location=Launcher.class.getProtectionDomain().getCodeSource().getLocation();
    JarInputStream jarInputStream=new JarInputStream(location.openStream());
    Manifest manifest=jarInputStream.getManifest();
    Attributes mainAttributes=manifest.getMainAttributes();
    String manifestClassPath=mainAttributes.getValue("String_Node_Str");
    if (extraClassPath != null && extraClassPath.length() > 0) {
      manifestClassPath+="String_Node_Str" + extraClassPath.replace(':',' ');
    }
    File directoryBase=new File(location.getFile()).getParentFile();
    StringBuffer classPath=new StringBuffer(location.getFile());
    StringTokenizer tokenizer=new StringTokenizer(manifestClassPath,"String_Node_Str" + File.pathSeparatorChar,false);
    while (tokenizer.hasMoreTokens()) {
      classPath.append(File.pathSeparatorChar);
      String file=tokenizer.nextToken();
      classPath.append(new File(directoryBase,file).getCanonicalPath());
    }
    System.setProperty("String_Node_Str",classPath.toString());
  }
 catch (  IOException e) {
    System.err.println("String_Node_Str");
  }
}
Program: 145777
Project: 145777
Buggy source:
public static String getDigest(String s){
  if (digest != null) {
    return digestToHexString(digest.digest(s.getBytes()));
  }
  return "String_Node_Str";
}

Fixed version (ground truth):
public static String getDigest(String s){
  if (digest != null && s != null) {
    return digestToHexString(digest.digest(s.getBytes()));
  }
  return "String_Node_Str";
}
Program: 145778
Project: 145778
Buggy source:
public Snip storageLoad(String name){
  Logger.debug("String_Node_Str" + name);
  Application app=Application.get();
  long start=app.start();
  Snip snip=null;
  PreparedStatement statement=null;
  ResultSet result=null;
  Connection connection=ConnectionManager.getConnection();
  try {
    statement=connection.prepareStatement("String_Node_Str" + "String_Node_Str" + "String_Node_Str"+ "String_Node_Str");
    statement.setString(1,name.toUpperCase());
    result=statement.executeQuery();
    if (result.next()) {
      snip=createSnip(result);
    }
  }
 catch (  SQLException e) {
    SQLLogger.warn("String_Node_Str" + name,e);
  }
 finally {
    ConnectionManager.close(result);
    ConnectionManager.close(statement);
    ConnectionManager.close(connection);
  }
  app.stop(start,"String_Node_Str" + name);
  return snip;
}

Fixed version (ground truth):
public Snip storageLoad(String name){
  if (cache.containsKey(name.toUpperCase())) {
    return (Snip)cache.get(name.toUpperCase());
  }
  Application app=Application.get();
  long start=app.start();
  Snip snip=null;
  PreparedStatement statement=null;
  ResultSet result=null;
  Connection connection=ConnectionManager.getConnection();
  try {
    statement=connection.prepareStatement("String_Node_Str" + "String_Node_Str" + "String_Node_Str"+ "String_Node_Str");
    statement.setString(1,name.toUpperCase());
    result=statement.executeQuery();
    if (result.next()) {
      snip=createSnip(result);
    }
  }
 catch (  SQLException e) {
    SQLLogger.warn("String_Node_Str" + name,e);
  }
 finally {
    ConnectionManager.close(result);
    ConnectionManager.close(statement);
    ConnectionManager.close(connection);
  }
  app.stop(start,"String_Node_Str" + name);
  return snip;
}
Program: 145780
Project: 145780
Buggy source:
public QuerySnipStorage(SnipStorage storage){
  this.storage=storage;
  this.nameComparator=new SnipComparator(){
    public int compare(    Snip s1,    Snip s2){
      return s1.getName().compareTo(s2.getName());
    }
  }
;
  this.nameComparatorDesc=new SnipComparator(){
    public int compare(    Snip s1,    Snip s2){
      return s2.getName().compareTo(s1.getName());
    }
  }
;
  this.cTimeComparator=new SnipComparator(){
    public int compare(    Snip s1,    Snip s2){
      return s2.getCTime().compareTo(s1.getCTime());
    }
  }
;
  this.mTimeComparatorDesc=new SnipComparator(){
    public int compare(    Snip s1,    Snip s2){
      return s2.getMTime().compareTo(s1.getMTime());
    }
  }
;
}

Fixed version (ground truth):
public QuerySnipStorage(SnipStorage storage){
  this.storage=storage;
  this.nameComparator=new SnipComparator(){
    public int compare(    Snip s1,    Snip s2){
      return s1.getName().compareTo(s2.getName());
    }
  }
;
  this.nameComparatorDesc=new SnipComparator(){
    public int compare(    Snip s1,    Snip s2){
      return s2.getName().compareTo(s1.getName());
    }
  }
;
  this.cTimeComparator=new SnipComparator(){
    public int compare(    Snip s1,    Snip s2){
      return s1.getCTime().compareTo(s2.getCTime());
    }
  }
;
  this.mTimeComparatorDesc=new SnipComparator(){
    public int compare(    Snip s1,    Snip s2){
      return s2.getMTime().compareTo(s1.getMTime());
    }
  }
;
}
Program: 145781
Project: 145781
Buggy source:
public QuerySnipStorage(SnipStorage storage){
  this.storage=storage;
  this.nameComparator=new SnipComparator(){
    public int compare(    Snip s1,    Snip s2){
      return s1.getName().compareTo(s2.getName());
    }
  }
;
  this.nameComparatorDesc=new SnipComparator(){
    public int compare(    Snip s1,    Snip s2){
      return s2.getName().compareTo(s1.getName());
    }
  }
;
  this.mTimeComparatorDesc=new SnipComparator(){
    public int compare(    Snip s1,    Snip s2){
      return s2.getMTime().compareTo(s1.getMTime());
    }
  }
;
}

Fixed version (ground truth):
public QuerySnipStorage(SnipStorage storage){
  this.storage=storage;
  this.nameComparator=new SnipComparator(){
    public int compare(    Snip s1,    Snip s2){
      return s1.getName().compareTo(s2.getName());
    }
  }
;
  this.nameComparatorDesc=new SnipComparator(){
    public int compare(    Snip s1,    Snip s2){
      return s2.getName().compareTo(s1.getName());
    }
  }
;
  this.cTimeComparator=new SnipComparator(){
    public int compare(    Snip s1,    Snip s2){
      return s2.getCTime().compareTo(s1.getCTime());
    }
  }
;
  this.mTimeComparatorDesc=new SnipComparator(){
    public int compare(    Snip s1,    Snip s2){
      return s2.getMTime().compareTo(s1.getMTime());
    }
  }
;
}
Program: 145782
Project: 145782
Buggy source:
public List storageByComments(final Snip parent){
  return QueryKit.querySorted(storage.storageAll(),new SnipQuery(){
    public boolean fit(    Snip snip){
      return (parent == snip.getCommentedSnip());
    }
  }
,nameComparator);
}

Fixed version (ground truth):
public List storageByComments(final Snip parent){
  return QueryKit.querySorted(storage.storageAll(),new SnipQuery(){
    public boolean fit(    Snip snip){
      return (parent == snip.getCommentedSnip());
    }
  }
,cTimeComparator);
}
Program: 145783
Project: 145783
Buggy source:
public void sendMail(String sender,Collection recipientList,String subject,String content){
  try {
    Message mesg=new MimeMessage(session);
    mesg.setFrom(new InternetAddress(sender));
    Iterator iterator=recipientList.iterator();
    while (iterator.hasNext()) {
      String recpt=(String)iterator.next();
      mesg.addRecipient(Message.RecipientType.TO,new InternetAddress(recpt));
    }
    mesg.setSubject(subject);
    Multipart mp=new MimeMultipart();
    BodyPart htmlPart=new MimeBodyPart();
    htmlPart.setContent(content,"String_Node_Str");
    mp.addBodyPart(htmlPart);
    mesg.setContent(mp);
    Transport.send(mesg);
  }
 catch (  MessagingException ex) {
    while ((ex=(MessagingException)ex.getNextException()) != null) {
      Logger.warn(ex.getMessage(),ex);
    }
  }
  return;
}

Fixed version (ground truth):
public void sendMail(String sender,Collection recipientList,String subject,String content){
  try {
    Message mesg=new MimeMessage(session);
    mesg.setFrom(new InternetAddress(sender));
    Iterator iterator=recipientList.iterator();
    while (iterator.hasNext()) {
      String recpt=(String)iterator.next();
      mesg.addRecipient(Message.RecipientType.TO,new InternetAddress(recpt));
    }
    mesg.setSubject(subject);
    Multipart mp=new MimeMultipart();
    BodyPart htmlPart=new MimeBodyPart();
    htmlPart.setContent(content,"String_Node_Str");
    mp.addBodyPart(htmlPart);
    mesg.setContent(mp);
    Transport.send(mesg);
  }
 catch (  MessagingException ex) {
    Exception e;
    while ((e=ex.getNextException()) != null) {
      Logger.warn(ex.getMessage(),e);
    }
  }
  return;
}
Program: 145784
Project: 145784
Buggy source:
public Object invoke(Invocation invocation) throws Throwable {
  if (invocation.getMethod().getName().startsWith("String_Node_Str")) {
    Snip snip=(Snip)invocation.getTarget();
    User user=Application.get().getUser();
    if (!user.isAdmin()) {
      if (!(Security.checkPermission("String_Node_Str",user,snip) && Security.hasRoles(user,snip,roles))) {
        throw new GeneralSecurityException("String_Node_Str");
      }
    }
  }
  return invocation.next();
}

Fixed version (ground truth):
public Object invoke(Invocation invocation) throws Throwable {
  if (invocation.getMethod().getName().startsWith("String_Node_Str")) {
    Snip snip=(Snip)invocation.getTarget();
    User user=Application.get().getUser();
    if (!user.isAdmin()) {
      if (!(Security.checkPermission("String_Node_Str",user,snip) || Security.hasRoles(user,snip,roles))) {
        throw new GeneralSecurityException(snip.getName() + "String_Node_Str" + user+ "String_Node_Str");
      }
    }
  }
  return invocation.next();
}
Program: 145785
Project: 145785
Buggy source:
public void doPost(HttpServletRequest request,HttpServletResponse response) throws ServletException, IOException {
  Snip snip=(Snip)request.getAttribute(SNIP);
  String fileName=(String)request.getAttribute(FILENAME);
  Attachment attachment=(Attachment)snip.getAttachments().getAttachment(fileName);
  if (attachment != null) {
    AppConfiguration config=Application.get().getConfiguration();
    File fileStore=new File(config.getFileStorePath());
    File file=new File(fileStore,attachment.getLocation());
    if (file.exists()) {
      response.setContentType(attachment.getContentType());
      response.setContentLength(attachment.getSize());
      BufferedOutputStream out=new BufferedOutputStream(response.getOutputStream());
      BufferedInputStream in=new BufferedInputStream(new FileInputStream(file));
      byte buf[]=new byte[4096];
      int length=-1;
      while ((length=in.read(buf)) != -1) {
        out.write(buf,0,length);
      }
      out.flush();
      in.close();
      out.close();
      return;
    }
  }
 else {
    Logger.log(Logger.DEBUG,"String_Node_Str" + fileName);
    String oldStyleFile="String_Node_Str" + snip.getName() + "String_Node_Str"+ fileName;
    RequestDispatcher dispatcher=request.getRequestDispatcher(oldStyleFile);
    if (dispatcher != null) {
      dispatcher.forward(request,response);
      return;
    }
  }
  throw new ServletException("String_Node_Str" + fileName);
}

Fixed version (ground truth):
public void doPost(HttpServletRequest request,HttpServletResponse response) throws ServletException, IOException {
  Snip snip=(Snip)request.getAttribute(SNIP);
  String fileName=(String)request.getAttribute(FILENAME);
  if (snip != null) {
    Attachment attachment=snip.getAttachments().getAttachment(fileName);
    if (attachment != null) {
      AppConfiguration config=Application.get().getConfiguration();
      File fileStore=new File(config.getFileStorePath());
      File file=new File(fileStore,attachment.getLocation());
      if (file.exists()) {
        response.setContentType(attachment.getContentType());
        response.setContentLength(attachment.getSize());
        BufferedOutputStream out=new BufferedOutputStream(response.getOutputStream());
        BufferedInputStream in=new BufferedInputStream(new FileInputStream(file));
        byte buf[]=new byte[4096];
        int length=-1;
        while ((length=in.read(buf)) != -1) {
          out.write(buf,0,length);
        }
        out.flush();
        in.close();
        out.close();
        return;
      }
    }
 else {
      Logger.log(Logger.DEBUG,"String_Node_Str" + fileName);
      String oldStyleFile="String_Node_Str" + snip.getName() + "String_Node_Str"+ fileName;
      RequestDispatcher dispatcher=request.getRequestDispatcher(oldStyleFile);
      if (dispatcher != null) {
        dispatcher.forward(request,response);
        return;
      }
    }
  }
  throw new ServletException("String_Node_Str" + fileName);
}
Program: 145786
Project: 145786
Buggy source:
/** 
 * Check if the user has the permission on the object. Returns true if there is no "Edit" permission.
 * @param permission the permission to check, e.g. "Edit"
 * @param user the user to check permissions for, e.g. "funzel"
 * @param object the object that should be manipulated
 * @return
 */
public static boolean checkPermission(String permission,User user,Snip object){
  Permissions permissions=object.getPermissions();
  if (null == permissions) {
    return true;
  }
 else {
    return permissions.check(permission,getRoles(user,object));
  }
}

Fixed version (ground truth):
/** 
 * Check if the user has the permission on the object. Returns true if there is no "Edit" permission.
 * @param permission the permission to check, e.g. "Edit"
 * @param user the user to check permissions for, e.g. "funzel"
 * @param object the object that should be manipulated
 * @return
 */
public static boolean checkPermission(String permission,User user,Snip object){
  Permissions permissions=object.getPermissions();
  if (null == permissions || permissions.empty()) {
    return true;
  }
 else {
    return permissions.check(permission,getRoles(user,object));
  }
}
Program: 145788
Project: 145788
Buggy source:
public void doPost(HttpServletRequest request,HttpServletResponse response) throws ServletException, IOException {
  HttpSession session=request.getSession();
  if (session != null) {
    String user=request.getParameter("String_Node_Str");
    String pass=request.getParameter("String_Node_Str");
    Configuration config=(Configuration)session.getAttribute(CommandHandler.ATT_CONFIG);
    if (config != null && config.getAdminLogin().equals(user) && config.getAdminPassword().equals(pass)) {
      org.snipsnap.server.Shutdown.shutdown();
      response.sendError(HttpServletResponse.SC_SERVICE_UNAVAILABLE,"String_Node_Str");
      return;
    }
  }
  response.sendRedirect(SnipLink.absoluteLink(request,"String_Node_Str"));
}

Fixed version (ground truth):
public void doPost(HttpServletRequest request,HttpServletResponse response) throws ServletException, IOException {
  HttpSession session=request.getSession();
  if (session != null) {
    String user=request.getParameter("String_Node_Str");
    String pass=request.getParameter("String_Node_Str");
    Configuration config=(Configuration)session.getAttribute(CommandHandler.ATT_CONFIG);
    if (config != null && config.getAdminLogin().equals(user) && config.getAdminPassword().equals(pass)) {
      response.sendError(HttpServletResponse.SC_SERVICE_UNAVAILABLE,"String_Node_Str");
      System.exit(0);
    }
  }
  response.sendRedirect(SnipLink.absoluteLink(request,"String_Node_Str"));
}
Program: 145790
Project: 145790
Buggy source:
/** 
 * Shut down complete server ...
 */
public static void shutdown(){
  new Thread(new Runnable(){
    public void run(){
      try {
        Thread.sleep(1000);
      }
 catch (      Exception e) {
        Code.ignore(e);
      }
      Log.event("String_Node_Str");
      System.out.println("String_Node_Str");
      Iterator s=HttpServer.getHttpServers().iterator();
      while (s.hasNext()) {
        HttpServer server=(HttpServer)s.next();
        try {
          System.out.println("String_Node_Str" + server);
          server.stop();
        }
 catch (        Exception e) {
          Code.ignore(e);
        }
      }
      System.out.println("String_Node_Str");
      Log.event("String_Node_Str");
      System.exit(0);
    }
  }
).start();
}

Fixed version (ground truth):
/** 
 * Shut down complete server ...
 */
public static void shutdown(){
  Log.event("String_Node_Str");
  System.out.println("String_Node_Str");
  Iterator s=HttpServer.getHttpServers().iterator();
  while (s.hasNext()) {
    HttpServer server=(HttpServer)s.next();
    try {
      System.out.println("String_Node_Str" + server);
      server.stop();
    }
 catch (    Exception e) {
      Code.ignore(e);
    }
  }
  System.out.println("String_Node_Str");
  Log.event("String_Node_Str");
}
Program: 145791
Project: 145791
Buggy source:
/** 
 * Start SnipSnap after adding the sdk tools.jar or similar to the classpath.
 * @param args command line arguments
 */
public static void main(String[] args){
  File toolsJar=new File(new File(System.getProperty("String_Node_Str")),"String_Node_Str");
  if (!toolsJar.exists()) {
    toolsJar=new File(new File(System.getProperty("String_Node_Str")),"String_Node_Str");
  }
  if (!toolsJar.exists()) {
    String system=System.getProperty("String_Node_Str");
    if (system.startsWith("String_Node_Str")) {
      toolsJar=new File("String_Node_Str");
    }
 else {
      System.out.println("String_Node_Str" + toolsJar);
      System.out.println("String_Node_Str");
      System.exit(-1);
    }
  }
  try {
    System.setProperty(Launcher.CLASSPATH,toolsJar.getCanonicalPath());
  }
 catch (  IOException e) {
    System.out.println("String_Node_Str" + e.getMessage());
  }
  if (null == System.getProperty(Launcher.ERRORLOG)) {
    System.setProperty(Launcher.ERRORLOG,"String_Node_Str");
  }
  try {
    invokeMain("String_Node_Str",args);
  }
 catch (  Exception e) {
    System.out.println("String_Node_Str" + e.getMessage());
    e.printStackTrace();
  }
}

Fixed version (ground truth):
/** 
 * Start SnipSnap after adding the sdk tools.jar or similar to the classpath.
 * @param args command line arguments
 */
public static void main(String[] args){
  File toolsJar=new File(new File(System.getProperty("String_Node_Str")),"String_Node_Str");
  if (!toolsJar.exists()) {
    toolsJar=new File(new File(System.getProperty("String_Node_Str")),"String_Node_Str");
  }
  if (!toolsJar.exists()) {
    String system=System.getProperty("String_Node_Str");
    if (system.startsWith("String_Node_Str")) {
      toolsJar=new File("String_Node_Str");
    }
 else {
      System.out.println("String_Node_Str" + toolsJar);
      System.out.println("String_Node_Str");
      System.out.println("String_Node_Str");
    }
  }
  try {
    System.setProperty(Launcher.CLASSPATH,toolsJar.getCanonicalPath());
  }
 catch (  IOException e) {
    System.out.println("String_Node_Str" + e.getMessage());
  }
  if (null == System.getProperty(Launcher.ERRORLOG)) {
    System.setProperty(Launcher.ERRORLOG,"String_Node_Str");
  }
  try {
    invokeMain("String_Node_Str",args);
  }
 catch (  Exception e) {
    System.out.println("String_Node_Str" + e.getMessage());
    e.printStackTrace();
  }
}
Program: 145792
Project: 145792
Buggy source:
private Aspects(Object target){
  this.target=target;
  interceptors=new ArrayList();
  Logger.debug("String_Node_Str" + target.getClass());
  if (target.getClass().equals(SnipImpl.class)) {
    interceptors.add(new ACLInterceptor());
  }
 else   if (target.getClass().equals(SnipSpaceImpl.class)) {
    interceptors.add(new SnipSpaceACLInterceptor());
    interceptors.add(new StoreInterceptor());
  }
}

Fixed version (ground truth):
private Aspects(Object target){
  this.target=target;
  interceptors=new ArrayList();
  if (target.getClass().equals(SnipImpl.class)) {
    interceptors.add(new ACLInterceptor());
  }
 else   if (target.getClass().equals(SnipSpaceImpl.class)) {
    interceptors.add(new SnipSpaceACLInterceptor());
    interceptors.add(new StoreInterceptor());
  }
}
Program: 145793
Project: 145793
Buggy source:
public void init(ServletConfig servletConfig) throws ServletException {
  XmlRpcServer xmlrpc=new XmlRpcServer();
  handlers=new ArrayList();
  handlers.add(new SnipSnapHandler());
  handlers.add(new BloggerHandler());
  handlers.add(new WeblogsPingHandler());
  handlers.add(new GeneratorHandler());
  handlers.add(new WeblogHandler());
  Iterator iterator=handlers.iterator();
  while (iterator.hasNext()) {
    XmlRpcHandler handler=(XmlRpcHandler)iterator.next();
    xmlrpc.addHandler(handler.getName(),handler);
  }
}

Fixed version (ground truth):
public void init(ServletConfig servletConfig) throws ServletException {
  xmlrpc=new XmlRpcServer();
  handlers=new ArrayList();
  handlers.add(new SnipSnapHandler());
  handlers.add(new MetaWeblogHandler());
  handlers.add(new BloggerHandler());
  handlers.add(new WeblogsPingHandler());
  handlers.add(new GeneratorHandler());
  handlers.add(new WeblogHandler());
  Iterator iterator=handlers.iterator();
  while (iterator.hasNext()) {
    XmlRpcHandler handler=(XmlRpcHandler)iterator.next();
    xmlrpc.addHandler(handler.getName(),handler);
  }
}
Program: 145794
Project: 145794
Buggy source:
/** 
 * metaWeblog.newPost (blogid, username, password, struct, publish) returns string metaWeblog.editPost (postid, username, password, struct, publish) returns true metaWeblog.getPost (postid, username, password) returns struct
 */
public String newPost(String blogid,String username,String password,String struct,String publish){
  return "String_Node_Str";
}

Fixed version (ground truth):
/** 
 * metaWeblog.newPost (blogid, username, password, struct, publish) returns string metaWeblog.editPost (postid, username, password, struct, publish) returns true metaWeblog.getPost (postid, username, password) returns struct
 */
public String newPost(String blogid,String username,String password,Hashtable struct,boolean publish) throws Exception {
  User user=authenticate(username,password);
  SnipSpace space=SnipSpaceFactory.getInstance();
  Hashtable postcontent=struct;
  String title=(String)postcontent.get("String_Node_Str");
  String content=(String)postcontent.get("String_Node_Str");
  Snip snip=null;
  if (null == title) {
    snip=space.post(content);
  }
 else {
    snip=space.post(content,title);
  }
  return snip.getName();
}
Program: 145795
Project: 145795
Buggy source:
public void run(){
  if (config.allow(AppConfiguration.PERM_WEBLOGS_PING) && handlers.size() > 0) {
    if (null == handlers) {
      init();
    }
    Iterator iterator=handlers.iterator();
    while (iterator.hasNext()) {
      PingHandler handler=(PingHandler)iterator.next();
      handler.ping(weblog);
    }
  }
}

Fixed version (ground truth):
public void run(){
  Logger.debug("String_Node_Str" + config);
  if (config.allow(AppConfiguration.PERM_WEBLOGS_PING)) {
    if (null == handlers) {
      init();
    }
    if (handlers.size() > 0) {
      Iterator iterator=handlers.iterator();
      while (iterator.hasNext()) {
        PingHandler handler=(PingHandler)iterator.next();
        handler.ping(weblog);
      }
    }
  }
}
Program: 145799
Project: 145799
Buggy source:
public MultipartWrapper(HttpServletRequest request) throws IOException, IllegalArgumentException {
  super(request);
  InputStreamDataSource ds=new InputStreamDataSource(request.getInputStream(),request.getContentType());
  try {
    multipart=new MimeMultipart(ds);
    params=new Hashtable(request.getParameterMap());
    int count=multipart.getCount();
    for (int i=0; i < count; i++) {
      MimeBodyPart body=(MimeBodyPart)multipart.getBodyPart(i);
      ContentDisposition disp=new ContentDisposition(body.getHeader("String_Node_Str",null));
      String name=disp.getParameter("String_Node_Str");
      if (body.getContentType().startsWith("String_Node_Str")) {
        String value=new String(((String)body.getContent()).getBytes("String_Node_Str"),request.getCharacterEncoding());
        String[] values=(String[])params.get(name);
        if (null == values) {
          params.put(name,new String[]{value});
        }
 else {
          String[] tmp=new String[values.length + 1];
          System.arraycopy(values,0,tmp,0,values.length);
          tmp[values.length + 1]=value;
        }
      }
 else {
        files.put(name,body);
      }
    }
  }
 catch (  MessagingException e) {
    e.printStackTrace();
    throw new IllegalArgumentException("String_Node_Str");
  }
}

Fixed version (ground truth):
public MultipartWrapper(HttpServletRequest request) throws IOException, IllegalArgumentException {
  super(request);
  InputStreamDataSource ds=new InputStreamDataSource(request.getInputStream(),request.getContentType());
  try {
    multipart=new MimeMultipart(ds);
    params=new Hashtable(request.getParameterMap());
    int count=multipart.getCount();
    for (int i=0; i < count; i++) {
      MimeBodyPart body=(MimeBodyPart)multipart.getBodyPart(i);
      ContentDisposition disp=new ContentDisposition(body.getHeader("String_Node_Str",null));
      String name=disp.getParameter("String_Node_Str");
      if (body.getContentType().startsWith("String_Node_Str")) {
        String value=new String(((String)body.getContent()).getBytes("String_Node_Str"),request.getCharacterEncoding());
        String[] values=(String[])params.get(name);
        if (null == values) {
          params.put(name,new String[]{value});
        }
 else {
          String[] tmp=new String[values.length + 1];
          System.arraycopy(values,0,tmp,0,values.length);
          tmp[tmp.length - 1]=value;
          params.put(name,tmp);
        }
      }
 else {
        files.put(name,body);
      }
    }
  }
 catch (  MessagingException e) {
    e.printStackTrace();
    throw new IllegalArgumentException("String_Node_Str");
  }
}
Program: 145800
Project: 145800
Buggy source:
public static void insertData(AppConfiguration config,InputStream data){
  System.out.println("String_Node_Str");
  SnipSpace.removeInstance();
  UserManager.removeInstance();
  User admin=UserManager.getInstance().create(config.getAdminLogin(),config.getAdminPassword(),config.getAdminEmail());
  admin.getRoles().add(Roles.EDITOR);
  UserManager.getInstance().store(admin);
  Application app=Application.get();
  app.setUser(admin);
  System.out.println("String_Node_Str");
  SnipSpace space=SnipSpace.getInstance();
  try {
    XMLSnipImport.load(data,true);
  }
 catch (  IOException e) {
    System.out.println("String_Node_Str");
  }
  space.post("String_Node_Str");
  System.out.println("String_Node_Str");
}

Fixed version (ground truth):
public static void insertData(AppConfiguration config,InputStream data){
  System.out.println("String_Node_Str");
  SnipSpace.removeInstance();
  UserManager.removeInstance();
  User admin=UserManager.getInstance().authenticate(config.getAdminLogin(),config.getAdminPassword());
  Application app=Application.get();
  app.setUser(admin);
  System.out.println("String_Node_Str");
  SnipSpace space=SnipSpace.getInstance();
  try {
    XMLSnipImport.load(data,true);
  }
 catch (  IOException e) {
    System.out.println("String_Node_Str");
  }
  space.post("String_Node_Str");
  System.out.println("String_Node_Str");
}
Program: 145801
Project: 145801
Buggy source:
public String getXMLContent(){
  String tmp=null;
  try {
    tmp=toXML();
  }
 catch (  Exception e) {
    e.printStackTrace();
    tmp="String_Node_Str" + e + "String_Node_Str";
  }
catch (  Error err) {
    err.printStackTrace();
    tmp="String_Node_Str" + err + "String_Node_Str";
  }
  return tmp;
}

Fixed version (ground truth):
public String getXMLContent(){
  String tmp=null;
  try {
    tmp=toXML();
  }
 catch (  Exception e) {
    tmp="String_Node_Str" + e + "String_Node_Str";
    e.printStackTrace();
  }
catch (  Error err) {
    err.printStackTrace();
    tmp="String_Node_Str" + err + "String_Node_Str";
  }
  return tmp;
}
Program: 145802
Project: 145802
Buggy source:
public String filter(String input,Snip snip){
  String output=input;
  Iterator filterIterator=filterList.iterator();
  while (filterIterator.hasNext()) {
    Filter f=(Filter)filterIterator.next();
    String tmp=f.filter(output,snip);
    if (null == tmp) {
      System.err.println("String_Node_Str" + f);
    }
 else {
      output=tmp;
    }
  }
  return output;
}

Fixed version (ground truth):
public String filter(String input,Snip snip){
  String output=input;
  Iterator filterIterator=filterList.iterator();
  while (filterIterator.hasNext()) {
    Filter f=(Filter)filterIterator.next();
    try {
      String tmp=f.filter(output,snip);
      if (null == tmp) {
        System.err.println("String_Node_Str" + f);
      }
 else {
        output=tmp;
      }
    }
 catch (    Exception e) {
      System.err.println("String_Node_Str" + f + "String_Node_Str"+ e);
      e.printStackTrace();
    }
  }
  return output;
}
Program: 145804
Project: 145804
Buggy source:
public String filter(String input,Snip snip){
  String result=input;
  int size=pattern.size();
  for (int i=0; i < size; i++) {
    Pattern p=(Pattern)pattern.get(i);
    String s=(String)substitute.get(i);
    try {
      result=Util.substitute(matcher,p,new Perl5Substitution(s,interps),result,limit);
    }
 catch (    Exception e) {
      Logger.log("String_Node_Str" + this + "String_Node_Str"+ e);
      e.printStackTrace();
    }
catch (    Error err) {
      Logger.log("String_Node_Str" + this + "String_Node_Str"+ err);
      err.printStackTrace();
    }
  }
  return result;
}

Fixed version (ground truth):
public String filter(String input,Snip snip){
  String result=input;
  int size=pattern.size();
  for (int i=0; i < size; i++) {
    Pattern p=(Pattern)pattern.get(i);
    String s=(String)substitute.get(i);
    try {
      result=Util.substitute(matcher,p,new Perl5Substitution(s,interps),result,limit);
    }
 catch (    Exception e) {
      Logger.log("String_Node_Str" + this + "String_Node_Str"+ e);
      System.err.println("String_Node_Str" + this);
      e.printStackTrace();
    }
catch (    Error err) {
      Logger.log("String_Node_Str" + this + "String_Node_Str"+ err);
      System.err.println("String_Node_Str" + this);
      err.printStackTrace();
    }
  }
  return result;
}
Program: 145805
Project: 145805
Buggy source:
public void doGet(HttpServletRequest request,HttpServletResponse response) throws IOException, ServletException {
  RequestDispatcher dispatcher=request.getRequestDispatcher("String_Node_Str");
  dispatcher.forward(request,response);
}

Fixed version (ground truth):
public void doGet(HttpServletRequest request,HttpServletResponse response) throws IOException, ServletException {
  String name="String_Node_Str";
  Snip snip=SnipSpace.getInstance().load(name);
  request.setAttribute("String_Node_Str",snip);
  request.setAttribute("String_Node_Str",SnipSpace.getInstance());
  request.setAttribute("String_Node_Str",config);
  request.setAttribute("String_Node_Str",config.getUrl("String_Node_Str"));
  RequestDispatcher dispatcher=request.getRequestDispatcher("String_Node_Str");
  dispatcher.forward(request,response);
}
Program: 145806
Project: 145806
Buggy source:
public int doStartTag() throws JspException {
  JspWriter out=pageContext.getOut();
  Links snipLinks=snip.getAccess().getSnipLinks();
  Iterator iterator=snipLinks.iterator();
  int size=snipLinks.getSize();
  int percentPerCell=100 / width;
  ColorRange cr=new ColorRange(start,end,Math.max(size <= 20 ? size : 20,8));
  try {
    int i=0;
    out.println("String_Node_Str");
    out.println("String_Node_Str");
    out.println("String_Node_Str");
    while (iterator.hasNext() && i <= 20) {
      if (i % width == 0 && i != 0) {
        out.print("String_Node_Str");
      }
      String url=(String)iterator.next();
      out.print("String_Node_Str");
      out.print(cr.getColor(i++));
      out.print("String_Node_Str");
      out.print(percentPerCell);
      out.print("String_Node_Str");
      out.print(SnipLink.createLink(url,SnipLink.cutLength(url,25)));
      out.println("String_Node_Str");
    }
    out.println("String_Node_Str");
  }
 catch (  IOException e) {
    System.err.println("String_Node_Str" + e);
  }
  return super.doStartTag();
}

Fixed version (ground truth):
public int doStartTag() throws JspException {
  JspWriter out=pageContext.getOut();
  Links snipLinks=snip.getAccess().getSnipLinks();
  Iterator iterator=snipLinks.iterator();
  int size=snipLinks.getSize();
  int percentPerCell=100 / width;
  ColorRange cr=new ColorRange(start,end,Math.max(size <= 20 ? size : 20,8));
  try {
    int i=0;
    out.println("String_Node_Str");
    out.println("String_Node_Str");
    out.println("String_Node_Str");
    while (iterator.hasNext() && i < 20) {
      if (i % width == 0 && i != 0) {
        out.print("String_Node_Str");
      }
      String url=(String)iterator.next();
      out.print("String_Node_Str");
      out.print(cr.getColor(i++));
      out.print("String_Node_Str");
      out.print(percentPerCell);
      out.print("String_Node_Str");
      out.print(SnipLink.createLink(url,SnipLink.cutLength(url,25)));
      out.println("String_Node_Str");
    }
    out.println("String_Node_Str");
  }
 catch (  IOException e) {
    System.err.println("String_Node_Str" + e);
  }
  return super.doStartTag();
}
Program: 145807
Project: 145807
Buggy source:
private void addList(StringBuffer buffer,BufferedReader reader) throws IOException {
  String lastBullet=null;
  String line=null;
  while ((line=reader.readLine()) != null) {
    line=line.trim();
    String bullet=line.substring(0,1);
    if (!bullet.equals(lastBullet)) {
      if (lastBullet != null) {
        buffer.append(closeList.get(lastBullet)).append("String_Node_Str");
      }
      buffer.append(openList.get(bullet)).append("String_Node_Str");
    }
    buffer.append("String_Node_Str");
    buffer.append(line.substring(line.indexOf(' ') + 1));
    buffer.append("String_Node_Str");
    lastBullet=bullet;
  }
  buffer.append(closeList.get(lastBullet));
}

Fixed version (ground truth):
private void addList(StringBuffer buffer,BufferedReader reader) throws IOException {
  String lastBullet=null;
  String line=null;
  while ((line=reader.readLine()) != null) {
    line=line.trim();
    String bullet=line.substring(0,1);
    Logger.log("String_Node_Str" + line + "String_Node_Str");
    Logger.log("String_Node_Str" + lastBullet + "String_Node_Str"+ bullet+ "String_Node_Str");
    if (!bullet.equals(lastBullet)) {
      Logger.log("String_Node_Str");
      if (lastBullet != null) {
        buffer.append(closeList.get(lastBullet)).append("String_Node_Str");
      }
      buffer.append(openList.get(bullet)).append("String_Node_Str");
    }
    buffer.append("String_Node_Str");
    buffer.append(line.substring(line.indexOf(' ') + 1));
    buffer.append("String_Node_Str");
    lastBullet=bullet;
  }
  buffer.append(closeList.get(lastBullet));
}