nus-yam/ex-repair huggingface dataset:
Program: 145808
Project: 145808
Buggy source:
public int doStartTag() throws JspException {
  if (null != snip) {
    Map dublinCore=DublinCore.generate(snip);
    try {
      JspWriter out=pageContext.getOut();
      if ("String_Node_Str".equals(format)) {
        Iterator iterator=dublinCore.keySet().iterator();
        while (iterator.hasNext()) {
          String name=(String)iterator.next();
          String value=(String)dublinCore.get(name);
          out.print("String_Node_Str");
          out.print(name);
          out.print("String_Node_Str");
          out.print(value);
          out.print("String_Node_Str");
          out.print(name);
          out.println("String_Node_Str");
        }
      }
 else {
        out.println("String_Node_Str");
        Iterator iterator=dublinCore.keySet().iterator();
        while (iterator.hasNext()) {
          String name=(String)iterator.next();
          String value=(String)dublinCore.get(name);
          out.print("String_Node_Str");
          out.print(name);
          out.print("String_Node_Str");
          out.print(value);
          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 {
  if (null != snip) {
    Map dublinCore=DublinCore.generate(snip);
    try {
      JspWriter out=pageContext.getOut();
      if ("String_Node_Str".equals(format)) {
        Iterator iterator=dublinCore.keySet().iterator();
        while (iterator.hasNext()) {
          String name=(String)iterator.next();
          String value=(String)dublinCore.get(name);
          out.print("String_Node_Str");
          out.print(name.toLowerCase());
          out.print("String_Node_Str");
          out.print(value);
          out.print("String_Node_Str");
          out.print(name);
          out.println("String_Node_Str");
        }
      }
 else {
        out.println("String_Node_Str");
        Iterator iterator=dublinCore.keySet().iterator();
        while (iterator.hasNext()) {
          String name=(String)iterator.next();
          String value=(String)dublinCore.get(name);
          out.print("String_Node_Str");
          out.print(capitalize(name));
          out.print("String_Node_Str");
          out.print(value);
          out.println("String_Node_Str");
        }
      }
    }
 catch (    IOException e) {
      System.err.println("String_Node_Str" + e);
    }
  }
  return super.doStartTag();
}
Program: 145810
Project: 145810
Buggy source:
public Snip post(Snip weblog,String content,Date date){
  String name=Snip.toName(date);
  Snip snip=null;
  if (exists(name)) {
    snip=load(name);
    snip.setContent(snip.getContent() + "String_Node_Str" + content);
  }
 else {
    snip=create(name,content);
  }
  snip.setParent(weblog);
  snip.addPermission(Permissions.EDIT,Roles.OWNER);
  store(snip);
  WeblogsPing.ping();
  return snip;
}

Fixed version (ground truth):
public Snip post(Snip weblog,String content,Date date){
  String name=Snip.toName(date);
  Snip snip=null;
  if (exists(name)) {
    snip=load(name);
    snip.setContent(snip.getContent() + "String_Node_Str" + content);
  }
 else {
    snip=create(name,content);
  }
  snip.setParent(weblog);
  snip.addPermission(Permissions.EDIT,Roles.OWNER);
  store(snip);
  WeblogsPing.ping(snip);
  return snip;
}
Program: 145811
Project: 145811
Buggy source:
public static void ping(){
  try {
    AppConfiguration config=Application.get().getConfiguration();
    if (config.allow(AppConfiguration.PERM_WEBLOGS_PING)) {
      XmlRpcClient xmlrpc=new XmlRpcClient("String_Node_Str");
      Vector params=new Vector();
      params.addElement(config.getName());
      params.addElement(config.getUrl());
      xmlrpc.execute("String_Node_Str",params);
    }
  }
 catch (  Exception e) {
    System.err.println("String_Node_Str");
  }
}

Fixed version (ground truth):
public static void ping(Snip weblog){
  try {
    AppConfiguration config=Application.get().getConfiguration();
    if (config.allow(AppConfiguration.PERM_WEBLOGS_PING)) {
      XmlRpcClient xmlrpc=new XmlRpcClient("String_Node_Str");
      Vector params=new Vector();
      params.addElement(config.getName());
      params.addElement(config.getSnipUrl(weblog.getName()));
      xmlrpc.execute("String_Node_Str",params);
    }
  }
 catch (  Exception e) {
    System.err.println("String_Node_Str");
  }
}
Program: 145812
Project: 145812
Buggy source:
public void run(){
}

Fixed version (ground truth):
public void run(){
  try {
    if (config.allow(AppConfiguration.PERM_WEBLOGS_PING)) {
      XmlRpcClient weblogs_com=new XmlRpcClient("String_Node_Str");
      Vector params=new Vector();
      params.addElement(config.getName());
      params.addElement(config.getSnipUrl(weblog.getName()));
      Object result=weblogs_com.execute("String_Node_Str",params);
      XmlRpcClient blo_gs=new XmlRpcClient("String_Node_Str");
      params.clear();
      params.addElement(config.getName());
      params.addElement(config.getUrl());
      params.addElement(config.getSnipUrl(weblog.getName()));
      params.addElement(config.getUrl() + "String_Node_Str");
      result=weblogs_com.execute("String_Node_Str",params);
      XmlRpcClient home=new XmlRpcClient("String_Node_Str");
      params.clear();
      params.addElement(config.getName());
      params.addElement(config.getSnipUrl(weblog.getName()));
      result=home.execute("String_Node_Str",params);
    }
  }
 catch (  Exception e) {
    System.err.println("String_Node_Str" + e);
  }
}
Program: 145813
Project: 145813
Buggy source:
public static void ping(Snip weblog){
  try {
    AppConfiguration config=Application.get().getConfiguration();
    if (config.allow(AppConfiguration.PERM_WEBLOGS_PING)) {
      XmlRpcClient xmlrpc=new XmlRpcClient("String_Node_Str");
      Vector params=new Vector();
      params.addElement(config.getName());
      params.addElement(config.getSnipUrl(weblog.getName()));
      xmlrpc.execute("String_Node_Str",params);
    }
  }
 catch (  Exception e) {
    System.err.println("String_Node_Str");
  }
}

Fixed version (ground truth):
public static void ping(Snip weblog){
  try {
    AppConfiguration config=Application.get().getConfiguration();
    if (config.allow(AppConfiguration.PERM_WEBLOGS_PING)) {
      XmlRpcClient xmlrpc=new XmlRpcClient("String_Node_Str");
      Vector params=new Vector();
      params.addElement(config.getName());
      params.addElement(config.getSnipUrl(weblog.getName()));
      Object result=xmlrpc.execute("String_Node_Str",params);
      System.err.println("String_Node_Str" + result);
    }
  }
 catch (  Exception e) {
    System.err.println("String_Node_Str");
  }
}
Program: 145814
Project: 145814
Buggy source:
/** 
 * Update a user, check validity and equality of the input.
 */
private boolean update(HttpServletRequest request,Map errors,User user){
  String email=request.getParameter("String_Node_Str");
  String nPass=request.getParameter("String_Node_Str");
  String nPass2=request.getParameter("String_Node_Str");
  String status=request.getParameter("String_Node_Str");
  String roles[]=request.getParameterValues("String_Node_Str");
  boolean modified=false;
  if (!user.getEmail().equals(email)) {
    modified=true;
    user.setEmail(email);
  }
  if (!user.getStatus().equals(status)) {
    modified=true;
    user.setStatus(status);
  }
  Roles newRoles=new Roles(parseRoles(roles));
  if (!user.getRoles().equals(newRoles)) {
    if (!newRoles.getRoleSet().isEmpty() && !Roles.allRoles().containsAll(newRoles.getRoleSet())) {
      errors.put("String_Node_Str",ERR_UNKNOWN_ROLES + Roles.allRoles());
    }
 else {
      modified=true;
      user.setRoles(newRoles);
    }
  }
  if (nPass != null && nPass.length() > 0) {
    if (nPass.equals(nPass2)) {
      modified=true;
      user.setPasswd(nPass);
    }
 else {
      errors.put("String_Node_Str",ERR_WRONG_PASSWORD);
    }
  }
  return modified;
}

Fixed version (ground truth):
/** 
 * Update a user, check validity and equality of the input.
 */
private boolean update(HttpServletRequest request,Map errors,User user){
  String email=request.getParameter("String_Node_Str");
  String nPass=request.getParameter("String_Node_Str");
  String nPass2=request.getParameter("String_Node_Str");
  String status=request.getParameter("String_Node_Str");
  String roles[]=request.getParameterValues("String_Node_Str");
  boolean modified=false;
  if ((user.getEmail() == null && email != null) || (user.getEmail() != null && !user.getEmail().equals(email))) {
    modified=true;
    user.setEmail(email);
  }
  if ((user.getStatus() == null && status != null) || (user.getStatus() != null && !user.getStatus().equals(status))) {
    modified=true;
    user.setStatus(status);
  }
  Roles newRoles=new Roles(parseRoles(roles));
  if (!user.getRoles().equals(newRoles)) {
    if (!newRoles.getRoleSet().isEmpty() && !Roles.allRoles().containsAll(newRoles.getRoleSet())) {
      errors.put("String_Node_Str",ERR_UNKNOWN_ROLES + Roles.allRoles());
    }
 else {
      modified=true;
      user.setRoles(newRoles);
    }
  }
  if (nPass != null && nPass.length() > 0) {
    if (nPass.equals(nPass2)) {
      modified=true;
      user.setPasswd(nPass);
    }
 else {
      errors.put("String_Node_Str",ERR_WRONG_PASSWORD);
    }
  }
  return modified;
}
Program: 145815
Project: 145815
Buggy source:
public WeblogsPing(AppConfiguration configuration,Snip weblog){
  this.config=configuration;
  this.weblog=weblog;
  start();
}

Fixed version (ground truth):
public WeblogsPing(AppConfiguration configuration,Snip weblog){
  this.config=configuration;
  this.weblog=weblog;
}
Program: 145816
Project: 145816
Buggy source:
public Snip post(Snip weblog,String content,Date date){
  String name=Snip.toName(date);
  Snip snip=null;
  if (exists(name)) {
    snip=load(name);
    snip.setContent(snip.getContent() + "String_Node_Str" + content);
  }
 else {
    snip=create(name,content);
  }
  snip.setParent(weblog);
  snip.addPermission(Permissions.EDIT,Roles.OWNER);
  store(snip);
  WeblogsPing.ping(snip);
  return snip;
}

Fixed version (ground truth):
public Snip post(Snip weblog,String content,Date date){
  String name=Snip.toName(date);
  Snip snip=null;
  if (exists(name)) {
    snip=load(name);
    snip.setContent(snip.getContent() + "String_Node_Str" + content);
  }
 else {
    snip=create(name,content);
  }
  snip.setParent(weblog);
  snip.addPermission(Permissions.EDIT,Roles.OWNER);
  store(snip);
  WeblogsPing.ping(weblog);
  return snip;
}
Program: 145817
Project: 145817
Buggy source:
public static void ping(Snip weblog){
  try {
    AppConfiguration config=Application.get().getConfiguration();
    if (config.allow(AppConfiguration.PERM_WEBLOGS_PING)) {
      XmlRpcClient xmlrpc=new XmlRpcClient("String_Node_Str");
      Vector params=new Vector();
      params.addElement(config.getName());
      params.addElement(config.getSnipUrl(weblog.getName()));
      Object result=xmlrpc.execute("String_Node_Str",params);
      System.err.println("String_Node_Str" + result);
    }
  }
 catch (  Exception e) {
    System.err.println("String_Node_Str");
  }
}

Fixed version (ground truth):
public static void ping(Snip weblog){
  new WeblogsPing(Application.get().getConfiguration(),weblog).start();
}
Program: 145818
Project: 145818
Buggy source:
public boolean allowExternalImages(){
  return allow(AppConfiguration.PERM_WEBLOGS_PING);
}

Fixed version (ground truth):
public boolean allowExternalImages(){
  return allow(AppConfiguration.PERM_EXTERNAL_IMAGES);
}
Program: 145819
Project: 145819
Buggy source:
public int doStartTag() throws JspException {
  try {
    name=(String)ExpressionEvaluatorManager.evaluate("String_Node_Str",name,String.class,this,pageContext);
    if (alt != null) {
      alt=(String)ExpressionEvaluatorManager.evaluate("String_Node_Str",alt,String.class,this,pageContext);
    }
    if (ext != null) {
      ext=(String)ExpressionEvaluatorManager.evaluate("String_Node_Str",alt,String.class,this,pageContext);
    }
  }
 catch (  JspException e) {
    System.err.println("String_Node_Str" + e);
  }
  JspWriter out=pageContext.getOut();
  try {
    out.print(SnipLink.createImage(name,alt != null ? alt : name,ext != null ? ext : "String_Node_Str"));
  }
 catch (  IOException e) {
    System.err.println("String_Node_Str" + name);
  }
  return SKIP_BODY;
}

Fixed version (ground truth):
public int doStartTag() throws JspException {
  try {
    name=(String)ExpressionEvaluatorManager.evaluate("String_Node_Str",name,String.class,this,pageContext);
    if (alt != null) {
      alt=(String)ExpressionEvaluatorManager.evaluate("String_Node_Str",alt,String.class,this,pageContext);
    }
    if (ext != null) {
      ext=(String)ExpressionEvaluatorManager.evaluate("String_Node_Str",ext,String.class,this,pageContext);
    }
  }
 catch (  JspException e) {
    System.err.println("String_Node_Str" + e);
  }
  JspWriter out=pageContext.getOut();
  try {
    out.print(SnipLink.createImage(name,alt != null ? alt : name,ext != null ? ext : "String_Node_Str"));
  }
 catch (  IOException e) {
    System.err.println("String_Node_Str" + name);
  }
  return SKIP_BODY;
}
Program: 145820
Project: 145820
Buggy source:
public void handle(HttpServletRequest request){
  incViewCount();
  String referrer=request.getHeader("String_Node_Str");
  if (null != referrer) {
    String domain=Application.get().getConfiguration().getDomain();
    if (referrer.startsWith(domain)) {
      int index=referrer.indexOf("String_Node_Str");
      if (index != -1) {
        String url=referrer.substring(index + "String_Node_Str".length());
        index=url.indexOf("String_Node_Str");
        if (index != -1) {
          url=url.substring(0,index);
        }
        index=url.indexOf("String_Node_Str");
        if (index != -1) {
          url=url.substring(0,index);
        }
        snipLinks.addLink(SnipLink.decode(url));
      }
    }
 else {
      backLinks.addLink(SnipLink.decode(referrer));
    }
  }
  store();
}

Fixed version (ground truth):
public void handle(HttpServletRequest request){
  incViewCount();
  String referrer=request.getHeader("String_Node_Str");
  if (null != referrer) {
    String domain=Application.get().getConfiguration().getDomain();
    if (referrer.startsWith(domain)) {
      int index=referrer.indexOf("String_Node_Str");
      if (index != -1) {
        String url=referrer.substring(index + "String_Node_Str".length());
        index=url.indexOf("String_Node_Str");
        if (index != -1) {
          url=url.substring(0,index);
        }
        index=url.indexOf("String_Node_Str");
        if (index != -1) {
          url=url.substring(0,index);
        }
        String name=SnipLink.decode(url);
        if (!"String_Node_Str".equals(name) && !snip.getName().equals(name)) {
          snipLinks.addLink(SnipLink.decode(url));
        }
      }
    }
 else {
      backLinks.addLink(SnipLink.decode(referrer));
    }
  }
  store();
}
Program: 145821
Project: 145821
Buggy source:
public void execute(StringBuffer buffer,String[] params,String content,Snip snip) throws IllegalArgumentException {
  buffer.append("String_Node_Str");
  buffer.append(content);
  if (null != params && params.length == 1) {
    buffer.append(params[0]);
  }
  buffer.append("String_Node_Str");
  buffer.append("String_Node_Str");
  return;
}

Fixed version (ground truth):
public void execute(StringBuffer buffer,String[] params,String content,Snip snip) throws IllegalArgumentException {
  buffer.append("String_Node_Str");
  buffer.append(content);
  if (null != params && params.length == 1) {
    buffer.append(params[0]);
  }
  buffer.append("String_Node_Str");
  return;
}
Program: 145822
Project: 145822
Buggy source:
public void handle(HttpServletRequest request){
  incViewCount();
  String referrer=request.getHeader("String_Node_Str");
  if (null != referrer) {
    int index=referrer.indexOf("String_Node_Str");
    if (index != -1) {
      String url=referrer.substring(index + "String_Node_Str".length());
      index=url.indexOf("String_Node_Str");
      if (index != -1) {
        url=url.substring(0,index);
      }
      snipLinks.addLink(SnipLink.decode(url));
    }
 else {
      backLinks.addLink(SnipLink.decode(referrer));
    }
  }
  store();
}

Fixed version (ground truth):
public void handle(HttpServletRequest request){
  incViewCount();
  String referrer=request.getHeader("String_Node_Str");
  if (null != referrer) {
    String domain=Application.get().getConfiguration().getDomain();
    if (referrer.startsWith(domain)) {
      int index=referrer.indexOf("String_Node_Str");
      if (index != -1) {
        String url=referrer.substring(index + "String_Node_Str".length());
        index=url.indexOf("String_Node_Str");
        if (index != -1) {
          url=url.substring(0,index);
        }
        index=url.indexOf("String_Node_Str");
        if (index != -1) {
          url=url.substring(0,index);
        }
        snipLinks.addLink(SnipLink.decode(url));
      }
    }
 else {
      backLinks.addLink(SnipLink.decode(referrer));
    }
  }
  store();
}
Program: 145823
Project: 145823
Buggy source:
private static void toXml(String objectName,ResultSet results,PrintWriter out) throws SQLException {
  ResultSetMetaData meta=results.getMetaData();
  int size=meta.getColumnCount();
  while (results.next()) {
    out.println("String_Node_Str" + objectName + "String_Node_Str");
    for (int i=1; i <= size; i++) {
      Object object=null;
      String value=null;
      try {
        value=results.getString(i);
      }
 catch (      Exception e) {
        object=results.getObject(i);
      }
      String name=meta.getColumnName(i);
      if (null != value || null != object) {
        out.print("String_Node_Str" + name + "String_Node_Str");
        if (object instanceof Timestamp) {
          Timestamp time=(Timestamp)object;
          out.print(time.getTime());
        }
 else {
          out.print(value);
        }
        out.println("String_Node_Str" + name + "String_Node_Str");
      }
    }
    out.println("String_Node_Str" + objectName + "String_Node_Str");
  }
}

Fixed version (ground truth):
private static void toXml(String objectName,ResultSet results,PrintWriter out) throws SQLException {
  ResultSetMetaData meta=results.getMetaData();
  int size=meta.getColumnCount();
  while (results.next()) {
    out.println("String_Node_Str" + objectName + "String_Node_Str");
    for (int i=1; i <= size; i++) {
      Object object=null;
      String value=null;
      try {
        value=results.getString(i);
      }
 catch (      Exception e) {
        object=results.getObject(i);
      }
      String name=meta.getColumnName(i);
      if (null != value || null != object) {
        out.print("String_Node_Str" + name + "String_Node_Str");
        if (object instanceof Timestamp) {
          Timestamp time=(Timestamp)object;
          out.print(time.getTime());
        }
 else {
          out.print(escape(value));
        }
        out.println("String_Node_Str" + name + "String_Node_Str");
      }
    }
    out.println("String_Node_Str" + objectName + "String_Node_Str");
  }
}
Program: 145824
Project: 145824
Buggy source:
public static Application getInstance(HttpSession session){
  if (session != null) {
    Application application=(Application)session.getAttribute("String_Node_Str");
    if (null == application) {
      application=Application.get();
    }
    instance.set(application);
    return application;
  }
  return null;
}

Fixed version (ground truth):
public static Application getInstance(HttpSession session){
  if (session != null) {
    Application application=(Application)session.getAttribute("String_Node_Str");
    if (null == application) {
      application=new Application();
    }
    instance.set(application);
    return application;
  }
  return null;
}
Program: 145825
Project: 145825
Buggy source:
public void doGet(HttpServletRequest request,HttpServletResponse response) throws IOException, ServletException {
  HttpSession session=request.getSession(true);
  Application app=Application.getInstance(session);
  User user=app.getUser();
  if (user == null) {
    user=UserManager.getInstance().getUser(request);
  }
  Cookie cookie=UserManager.getInstance().getCookie(request,"String_Node_Str");
  if (null == cookie) {
    cookie=new Cookie("String_Node_Str",user.getLogin());
  }
  cookie.setPath(request.getContextPath());
  cookie.setMaxAge(Integer.MAX_VALUE - 2);
  response.addCookie(cookie);
  app.setUser(user);
  session.setAttribute("String_Node_Str",app);
  session.setAttribute("String_Node_Str",SnipSpace.getInstance());
  String layout=URLDecoder.decode(request.getPathInfo());
  if (null == layout || "String_Node_Str".equals(layout)) {
    response.sendRedirect(SnipLink.absoluteLink(request,"String_Node_Str"));
    return;
  }
  request.setAttribute("String_Node_Str",layout);
  RequestDispatcher dispatcher=null;
  if (layout.endsWith("String_Node_Str")) {
    dispatcher=request.getRequestDispatcher("String_Node_Str");
  }
 else {
    dispatcher=request.getRequestDispatcher(layout);
  }
  if (dispatcher != null) {
    dispatcher.forward(request,response);
  }
 else {
    response.sendRedirect(SnipLink.absoluteLink(request,"String_Node_Str"));
  }
}

Fixed version (ground truth):
public void doGet(HttpServletRequest request,HttpServletResponse response) throws IOException, ServletException {
  HttpSession session=request.getSession(true);
  Application app=Application.getInstance(session);
  User user=app.getUser();
  if (user == null) {
    user=UserManager.getInstance().getUser(request);
  }
  Cookie cookie=UserManager.getInstance().getCookie(request,"String_Node_Str");
  if (null == cookie) {
    cookie=new Cookie("String_Node_Str",user.getLogin());
  }
  cookie.setPath(request.getContextPath());
  cookie.setMaxAge(Integer.MAX_VALUE - 2);
  response.addCookie(cookie);
  app.setUser(user);
  session.setAttribute("String_Node_Str",app);
  session.setAttribute("String_Node_Str",SnipSpace.getInstance());
  String layout=URLDecoder.decode(request.getPathInfo());
  if (null == layout || "String_Node_Str".equals(layout)) {
    response.sendRedirect(SnipLink.absoluteLink(request,"String_Node_Str"));
    return;
  }
  request.setAttribute("String_Node_Str",layout);
  RequestDispatcher dispatcher=null;
  if (layout.endsWith("String_Node_Str")) {
    dispatcher=request.getRequestDispatcher("String_Node_Str");
  }
 else {
    dispatcher=request.getRequestDispatcher(layout);
  }
  if (dispatcher != null) {
    dispatcher.forward(request,response);
    Application.set(null);
  }
 else {
    response.sendRedirect(SnipLink.absoluteLink(request,"String_Node_Str"));
  }
}
Program: 145826
Project: 145826
Buggy source:
public void handleMatch(StringBuffer buffer,MatchResult result,Snip snip){
  String[] params=null;
  String content=null;
  String command=result.group(1);
  if (result.group(1).equals(result.group(result.groups() - 1))) {
    if (!"String_Node_Str".equals(result.group(2))) {
      params=split(result.group(2),"String_Node_Str");
    }
    content=result.group(3);
  }
 else {
    if (result.groups() > 1) {
      params=split(result.group(2),"String_Node_Str");
    }
  }
  try {
    if (macros.containsKey(command)) {
      Macro macro=(Macro)macros.get(command);
      if (null != content) {
        content=filter(content,snip);
      }
      macro.execute(buffer,params,content,snip);
    }
 else     if (command.startsWith("String_Node_Str")) {
      return;
    }
 else {
      buffer.append(result.group(0));
      return;
    }
  }
 catch (  Exception e) {
    System.err.println("String_Node_Str" + result.group(1));
    e.printStackTrace();
    buffer.append("String_Node_Str" + result.group(1) + (result.length() > 1 ? "String_Node_Str" + result.group(2) : "String_Node_Str")+ "String_Node_Str");
    return;
  }
}

Fixed version (ground truth):
public void handleMatch(StringBuffer buffer,MatchResult result,Snip snip){
  String[] params=null;
  String content=null;
  String command=result.group(1);
  if (result.group(1).equals(result.group(result.groups() - 1))) {
    if (!"String_Node_Str".equals(result.group(2))) {
      params=split(result.group(2),"String_Node_Str");
    }
    content=result.group(3);
  }
 else {
    if (result.groups() > 1) {
      params=split(result.group(2),"String_Node_Str");
    }
  }
  try {
    if (macros.containsKey(command)) {
      Macro macro=(Macro)macros.get(command);
      if (null != content) {
        content=filter(content,snip);
      }
      macro.execute(buffer,params,content,snip);
    }
 else     if (command.startsWith("String_Node_Str")) {
      Snip includeSnip=SnipSpace.getInstance().load(command.substring(1));
      buffer.append(includeSnip.getContent());
      return;
    }
 else {
      buffer.append(result.group(0));
      return;
    }
  }
 catch (  Exception e) {
    System.err.println("String_Node_Str" + result.group(1));
    e.printStackTrace();
    buffer.append("String_Node_Str" + command + (result.length() > 1 ? "String_Node_Str" + result.group(2) : "String_Node_Str")+ "String_Node_Str");
    return;
  }
}
Program: 145827
Project: 145827
Buggy source:
/** 
 * Generate a pretty print of the difference between the timestamp and now. e.g. show minutes, minutes and hours and days since now. "3 hours, 5 minutes ago.", "4 days ago."
 * @param time Timestamp to pretty print
 * @return Pretty string
 */
public static String getNiceTime(Timestamp time){
  if (time == null)   return "String_Node_Str";
  java.util.Date now=new java.util.Date();
  int secs=(int)(now.getTime() - time.getTime()) / 1000;
  int mins=secs / 60;
  int min=mins % 60;
  int hours=mins / 60;
  int hour=hours % 24;
  int days=hours / 24;
  StringBuffer nice=new StringBuffer();
  if (mins == 0) {
    nice.append("String_Node_Str");
  }
 else   if (hours == 0) {
    StringUtil.plural(nice,min,"String_Node_Str");
    nice.append("String_Node_Str");
  }
 else   if (days == 0) {
    StringUtil.plural(nice,hour,"String_Node_Str");
    nice.append("String_Node_Str");
    StringUtil.plural(nice,min,"String_Node_Str");
    nice.append("String_Node_Str");
  }
 else {
    StringUtil.plural(nice,days,"String_Node_Str");
    nice.append("String_Node_Str");
  }
  return nice.toString();
}

Fixed version (ground truth):
/** 
 * Generate a pretty print of the difference between the timestamp and now. e.g. show minutes, minutes and hours and days since now. "3 hours, 5 minutes ago.", "4 days ago."
 * @param time Timestamp to pretty print
 * @return Pretty string
 */
public static String getNiceTime(Timestamp time){
  if (time == null)   return "String_Node_Str";
  java.util.Date now=new java.util.Date();
  long secs=(now.getTime() - time.getTime()) / 1000;
  long mins=secs / 60;
  int min=(int)mins % 60;
  long hours=mins / 60;
  int hour=(int)hours % 24;
  int days=(int)hours / 24;
  StringBuffer nice=new StringBuffer();
  if (mins == 0) {
    nice.append("String_Node_Str");
  }
 else   if (hours == 0) {
    StringUtil.plural(nice,min,"String_Node_Str");
    nice.append("String_Node_Str");
  }
 else   if (days == 0) {
    StringUtil.plural(nice,hour,"String_Node_Str");
    nice.append("String_Node_Str");
    StringUtil.plural(nice,min,"String_Node_Str");
    nice.append("String_Node_Str");
  }
 else {
    StringUtil.plural(nice,days,"String_Node_Str");
    nice.append("String_Node_Str");
  }
  return nice.toString();
}
Program: 145828
Project: 145828
Buggy source:
public static Document Document(Snip snip){
  Document doc=new Document();
  doc.add(Field.Text("String_Node_Str",snip.getContent()));
  doc.add(Field.Text("String_Node_Str",snip.getName()));
  return doc;
}

Fixed version (ground truth):
public static Document Document(Snip snip){
  Document doc=new Document();
  doc.add(Field.Text("String_Node_Str",snip.getName().hashCode() + "String_Node_Str"));
  doc.add(Field.Text("String_Node_Str",snip.getContent()));
  doc.add(Field.Text("String_Node_Str",snip.getName()));
  return doc;
}
Program: 145829
Project: 145829
Buggy source:
public Hits search(String queryString){
  Searcher searcher=null;
  try {
    searcher=new IndexSearcher(indexFile);
  }
 catch (  IOException e) {
    System.out.println("String_Node_Str" + indexFile);
  }
  Query query=null;
  try {
    query=QueryParser.parse(queryString,"String_Node_Str",new StopAnalyzer());
  }
 catch (  org.apache.lucene.queryParser.ParseException e1) {
    close(searcher);
    System.out.println("String_Node_Str" + queryString);
  }
  Hits hits=null;
  try {
    hits=searcher.search(query);
  }
 catch (  IOException e) {
    close(searcher);
    System.out.println("String_Node_Str");
    e.printStackTrace();
  }
  return hits;
}

Fixed version (ground truth):
public Hits search(String queryString){
  Searcher searcher=null;
  try {
    searcher=new IndexSearcher(indexFile);
  }
 catch (  IOException e) {
    System.out.println("String_Node_Str" + indexFile);
    e.printStackTrace();
  }
  Query query=null;
  try {
    query=QueryParser.parse(queryString,"String_Node_Str",new SnipAnalyzer());
  }
 catch (  org.apache.lucene.queryParser.ParseException e1) {
    close(searcher);
    System.out.println("String_Node_Str" + queryString);
  }
  Hits hits=null;
  try {
    hits=searcher.search(query);
  }
 catch (  IOException e) {
    close(searcher);
    System.out.println("String_Node_Str");
    e.printStackTrace();
  }
  return hits;
}
Program: 145830
Project: 145830
Buggy source:
public void removeIndex(Snip snip){
  try {
    IndexReader reader=IndexReader.open(indexFile);
    reader.delete(new Term("String_Node_Str",snip.getName()));
  }
 catch (  IOException e) {
    System.err.println("String_Node_Str" + snip.getName() + "String_Node_Str");
  }
  return;
}

Fixed version (ground truth):
public void removeIndex(Snip snip){
  IndexReader reader=null;
  try {
    reader=IndexReader.open(indexFile);
    System.err.println("String_Node_Str" + reader.delete(new Term("String_Node_Str",snip.getName().hashCode() + "String_Node_Str")));
  }
 catch (  IOException e) {
    System.err.println("String_Node_Str" + snip.getName() + "String_Node_Str");
    e.printStackTrace();
  }
 finally {
    close(reader);
  }
  return;
}
Program: 145831
Project: 145831
Buggy source:
public void index(Snip snip){
  IndexWriter writer=null;
  try {
    File f;
    boolean create=true;
    if ((f=new File(indexFile)).exists() && f.isDirectory()) {
      create=false;
    }
 else {
      create=true;
    }
    writer=new IndexWriter(indexFile,new StopAnalyzer(),create);
    writer.mergeFactor=20;
    writer.addDocument(SnipDocument.Document(snip));
    writer.optimize();
  }
 catch (  IOException e) {
    System.err.println("String_Node_Str");
  }
 finally {
    close(writer);
  }
}

Fixed version (ground truth):
private void index(Snip snip,boolean exists){
  IndexWriter writer=null;
  if (exists) {
    removeIndex(snip);
  }
  try {
    File f;
    boolean create=true;
    if ((f=new File(indexFile)).exists() && f.isDirectory()) {
      create=false;
    }
 else {
      create=true;
    }
    writer=new IndexWriter(indexFile,new SnipAnalyzer(),create);
    writer.mergeFactor=20;
    writer.addDocument(SnipDocument.Document(snip));
    writer.optimize();
  }
 catch (  IOException e) {
    System.err.println("String_Node_Str");
    e.printStackTrace();
  }
 finally {
    close(writer);
  }
}
Program: 145832
Project: 145832
Buggy source:
private static void close(Searcher searcher){
  if (null != searcher) {
    try {
      searcher.close();
    }
 catch (    Exception e) {
    }
  }
}

Fixed version (ground truth):
private static void close(IndexReader reader){
  if (null != reader) {
    try {
      reader.close();
    }
 catch (    Exception e) {
    }
  }
}
Program: 145833
Project: 145833
Buggy source:
public void store(Snip snip){
  changed.add(snip);
  snip.setMTime(new Timestamp(new java.util.Date().getTime()));
  storageStore(snip);
  indexer.index(snip);
  return;
}

Fixed version (ground truth):
public void store(Snip snip){
  changed.add(snip);
  snip.setMTime(new Timestamp(new java.util.Date().getTime()));
  storageStore(snip);
  indexer.reIndex(snip);
  return;
}
Program: 145834
Project: 145834
Buggy source:
private String[] split(String s,String delim){
  StringTokenizer tok=new StringTokenizer(s,delim,false);
  List list=new ArrayList();
  while (tok.hasMoreTokens()) {
    list.add(tok.nextToken());
  }
  return (String[])list.toArray();
}

Fixed version (ground truth):
private String[] split(String s,String delim){
  StringTokenizer tok=new StringTokenizer(s,delim,false);
  List list=new ArrayList();
  while (tok.hasMoreTokens()) {
    list.add(tok.nextToken());
  }
  String tmp[]=new String[list.size()];
  tmp=(String[])list.toArray(tmp);
  return tmp;
}
Program: 145835
Project: 145835
Buggy source:
private void storageStore(User user){
  PreparedStatement statement=null;
  Connection connection=ConnectionManager.getConnection();
  try {
    statement=connection.prepareStatement("String_Node_Str");
    statement.setString(1,user.getLogin());
    statement.setString(2,user.getPasswd());
    statement.setString(3,user.getEmail());
    statement.setString(3,user.getStatus());
    statement.setString(4,serialize(user.getRoles()));
    statement.execute();
  }
 catch (  SQLException e) {
    e.printStackTrace();
  }
 finally {
    ConnectionManager.close(statement);
    ConnectionManager.close(connection);
  }
  return;
}

Fixed version (ground truth):
private void storageStore(User user){
  PreparedStatement statement=null;
  Connection connection=ConnectionManager.getConnection();
  try {
    statement=connection.prepareStatement("String_Node_Str" + "String_Node_Str");
    statement.setString(1,user.getLogin());
    statement.setString(2,user.getPasswd());
    statement.setString(3,user.getEmail());
    statement.setString(4,user.getStatus());
    statement.setString(5,serialize(user.getRoles()));
    statement.setString(6,user.getLogin());
    statement.execute();
  }
 catch (  SQLException e) {
    e.printStackTrace();
  }
 finally {
    ConnectionManager.close(statement);
    ConnectionManager.close(connection);
  }
  return;
}
Program: 145836
Project: 145836
Buggy source:
public String execute(String[] params,String content,Snip snip) throws IllegalArgumentException {
  StringBuffer buffer=new StringBuffer();
  buffer.append("String_Node_Str");
  if (params.length == 2) {
    buffer.append("String_Node_Str").append(params[1]).append("String_Node_Str");
  }
 else   if (params.length == 1) {
    buffer.append("String_Node_Str").append(params[0]).append("String_Node_Str");
  }
 else {
    throw new IllegalArgumentException("String_Node_Str");
  }
  return (buffer.append(params[0]).append("String_Node_Str")).toString();
}

Fixed version (ground truth):
public String execute(String[] params,String content,Snip snip) throws IllegalArgumentException {
  StringBuffer buffer=new StringBuffer();
  if (params.length == 2) {
    buffer.append("String_Node_Str");
    buffer.append("String_Node_Str").append(params[1]).append("String_Node_Str");
    buffer.append(params[0]).append("String_Node_Str");
  }
 else   if (params.length == 1) {
    buffer.append(append(params[0]));
  }
 else {
    throw new IllegalArgumentException("String_Node_Str");
  }
  return buffer.toString();
}
Program: 145837
Project: 145837
Buggy source:
public void doGet(HttpServletRequest request,HttpServletResponse response) throws IOException, ServletException {
  String name=request.getParameter("String_Node_Str");
  if (null == name) {
    response.sendRedirect(SnipLink.absoluteLink(request,"String_Node_Str"));
    return;
  }
  Snip snip=SnipSpace.getInstance().load(name);
  request.setAttribute("String_Node_Str",snip);
  request.setAttribute("String_Node_Str",name);
  RequestDispatcher dispatcher=request.getRequestDispatcher(SnipLink.absoluteLink(request,"String_Node_Str"));
  dispatcher.forward(request,response);
}

Fixed version (ground truth):
public void doGet(HttpServletRequest request,HttpServletResponse response) throws IOException, ServletException {
  String name=request.getParameter("String_Node_Str");
  if (null == name) {
    response.sendRedirect(SnipLink.absoluteLink(request,"String_Node_Str"));
    return;
  }
  Snip snip=SnipSpace.getInstance().load(name);
  request.setAttribute("String_Node_Str",snip);
  request.setAttribute("String_Node_Str",name);
  RequestDispatcher dispatcher=request.getRequestDispatcher("String_Node_Str");
  dispatcher.forward(request,response);
}
Program: 145838
Project: 145838
Buggy source:
public String execute(String[] params,String content,Snip snip) throws IllegalArgumentException {
  StringBuffer buffer=new StringBuffer();
  if (params.length == 2) {
    buffer.append("String_Node_Str");
    SnipLink.appendImage(buffer,"String_Node_Str","String_Node_Str","String_Node_Str");
    buffer.append("String_Node_Str").append(params[1]).append("String_Node_Str");
    buffer.append(params[0]).append("String_Node_Str");
    buffer.append("String_Node_Str");
  }
 else   if (params.length == 1) {
    buffer.append(params[0]);
  }
 else {
    throw new IllegalArgumentException("String_Node_Str");
  }
  return buffer.toString();
}

Fixed version (ground truth):
public String execute(String[] params,String content,Snip snip) throws IllegalArgumentException {
  StringBuffer buffer=new StringBuffer();
  if (params.length == 2) {
    buffer.append("String_Node_Str");
    buffer.append(img);
    buffer.append("String_Node_Str").append(params[1]).append("String_Node_Str");
    buffer.append(params[0]).append("String_Node_Str");
    buffer.append("String_Node_Str");
  }
 else   if (params.length == 1) {
    buffer.append(params[0]);
  }
 else {
    throw new IllegalArgumentException("String_Node_Str");
  }
  return buffer.toString();
}
Program: 145839
Project: 145839
Buggy source:
public Snip createSnip(ResultSet result) throws SQLException {
  String name=result.getString("String_Node_Str");
  String content=result.getString("String_Node_Str");
  Snip snip=new Snip(name,content);
  snip.setCTime(result.getTimestamp("String_Node_Str"));
  snip.setMTime(result.getTimestamp("String_Node_Str"));
  snip.setCUser(result.getString("String_Node_Str"));
  snip.setMUser(result.getString("String_Node_Str"));
  String commentString=result.getString("String_Node_Str");
  if (!result.wasNull()) {
    snip.setComment(load(commentString));
  }
  String parentString=result.getString("String_Node_Str");
  if (!result.wasNull()) {
    snip.parent=load(parentString);
  }
  return snip;
}

Fixed version (ground truth):
public Snip createSnip(ResultSet result) throws SQLException {
  String name=result.getString("String_Node_Str");
  String content=result.getString("String_Node_Str");
  Snip snip=new Snip(name,content);
  snip.setCTime(result.getTimestamp("String_Node_Str"));
  snip.setMTime(result.getTimestamp("String_Node_Str"));
  snip.setCUser(result.getString("String_Node_Str"));
  snip.setMUser(result.getString("String_Node_Str"));
  String commentString=result.getString("String_Node_Str");
  if (!result.wasNull()) {
    snip.setComment(load(commentString));
  }
  String parentString=result.getString("String_Node_Str");
  if (!result.wasNull()) {
    snip.parent=load(parentString);
  }
  snip.setPermissions(deserialize(result.getString("String_Node_Str")));
  return snip;
}
Program: 145840
Project: 145840
Buggy source:
private Snip storageCreate(String name,String content,Application app){
  PreparedStatement statement=null;
  ResultSet result=null;
  Connection connection=ConnectionManager.getConnection();
  String login=app.getUser().getLogin();
  Snip snip=new Snip(name,content);
  Timestamp cTime=new Timestamp(new java.util.Date().getTime());
  Timestamp mTime=(Timestamp)cTime.clone();
  snip.setCTime(cTime);
  snip.setMTime(mTime);
  snip.setCUser(login);
  snip.setMUser(login);
  try {
    statement=connection.prepareStatement("String_Node_Str" + "String_Node_Str" + "String_Node_Str");
    statement.setString(1,name);
    statement.setString(2,content);
    statement.setTimestamp(3,cTime);
    statement.setTimestamp(4,mTime);
    statement.setString(5,login);
    statement.setString(6,login);
    Snip parent=snip.getParent();
    if (null == parent) {
      statement.setNull(7,Types.VARCHAR);
    }
 else {
      statement.setString(7,parent.getName());
    }
    Snip comment=snip.getComment();
    if (null == comment) {
      statement.setNull(8,Types.VARCHAR);
    }
 else {
      statement.setString(8,comment.getName());
    }
    statement.execute();
  }
 catch (  SQLException e) {
    e.printStackTrace();
  }
 finally {
    ConnectionManager.close(result);
    ConnectionManager.close(statement);
    ConnectionManager.close(connection);
  }
  return snip;
}

Fixed version (ground truth):
private Snip storageCreate(String name,String content,Application app){
  PreparedStatement statement=null;
  ResultSet result=null;
  Connection connection=ConnectionManager.getConnection();
  String login=app.getUser().getLogin();
  Snip snip=new Snip(name,content);
  Timestamp cTime=new Timestamp(new java.util.Date().getTime());
  Timestamp mTime=(Timestamp)cTime.clone();
  snip.setCTime(cTime);
  snip.setMTime(mTime);
  snip.setCUser(login);
  snip.setMUser(login);
  try {
    statement=connection.prepareStatement("String_Node_Str" + "String_Node_Str" + "String_Node_Str");
    statement.setString(1,name);
    statement.setString(2,content);
    statement.setTimestamp(3,cTime);
    statement.setTimestamp(4,mTime);
    statement.setString(5,login);
    statement.setString(6,login);
    Snip parent=snip.getParent();
    if (null == parent) {
      statement.setNull(7,Types.VARCHAR);
    }
 else {
      statement.setString(7,parent.getName());
    }
    Snip comment=snip.getComment();
    if (null == comment) {
      statement.setNull(8,Types.VARCHAR);
    }
 else {
      statement.setString(8,comment.getName());
    }
    statement.setString(9,serialize(snip.getPermissions()));
    statement.execute();
  }
 catch (  SQLException e) {
    e.printStackTrace();
  }
 finally {
    ConnectionManager.close(result);
    ConnectionManager.close(statement);
    ConnectionManager.close(connection);
  }
  return snip;
}
Program: 145841
Project: 145841
Buggy source:
private void storageStore(Snip snip){
  PreparedStatement statement=null;
  Connection connection=ConnectionManager.getConnection();
  try {
    statement=connection.prepareStatement("String_Node_Str" + "String_Node_Str" + "String_Node_Str");
    statement.setString(1,snip.getName());
    statement.setString(2,snip.getContent());
    statement.setTimestamp(3,snip.getCTime());
    statement.setTimestamp(4,snip.getMTime());
    statement.setString(5,snip.getCUser());
    statement.setString(6,snip.getMUser());
    Snip parent=snip.getParent();
    if (null == parent) {
      statement.setNull(7,Types.VARCHAR);
    }
 else {
      statement.setString(7,parent.getName());
    }
    Snip comment=snip.getComment();
    if (null == comment) {
      statement.setNull(8,Types.VARCHAR);
    }
 else {
      statement.setString(8,comment.getName());
    }
    statement.setString(9,snip.getName());
    statement.execute();
  }
 catch (  SQLException e) {
    e.printStackTrace();
  }
 finally {
    ConnectionManager.close(statement);
    ConnectionManager.close(connection);
  }
  return;
}

Fixed version (ground truth):
private void storageStore(Snip snip){
  PreparedStatement statement=null;
  Connection connection=ConnectionManager.getConnection();
  try {
    statement=connection.prepareStatement("String_Node_Str" + "String_Node_Str" + "String_Node_Str");
    statement.setString(1,snip.getName());
    statement.setString(2,snip.getContent());
    statement.setTimestamp(3,snip.getCTime());
    statement.setTimestamp(4,snip.getMTime());
    statement.setString(5,snip.getCUser());
    statement.setString(6,snip.getMUser());
    Snip parent=snip.getParent();
    if (null == parent) {
      statement.setNull(7,Types.VARCHAR);
    }
 else {
      statement.setString(7,parent.getName());
    }
    Snip comment=snip.getComment();
    if (null == comment) {
      statement.setNull(8,Types.VARCHAR);
    }
 else {
      statement.setString(8,comment.getName());
    }
    statement.setString(9,serialize(snip.getPermissions()));
    statement.setString(10,snip.getName());
    statement.execute();
  }
 catch (  SQLException e) {
    e.printStackTrace();
  }
 finally {
    ConnectionManager.close(statement);
    ConnectionManager.close(connection);
  }
  return;
}
Program: 145842
Project: 145842
Buggy source:
public static boolean checkPermission(String permission,User user,Snip object){
  Map permissions=object.getPermissions();
  Set permRoles=(Set)permissions.get(permission);
  permRoles.removeAll(getRoles(user,object));
  return !permRoles.isEmpty();
}

Fixed version (ground truth):
/** 
 * Check if the user has the permission on the object
 * @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){
  Map permissions=object.getPermissions();
  Set permRoles=(Set)permissions.get(permission);
  permRoles.removeAll(getRoles(user,object));
  return !permRoles.isEmpty();
}
Program: 145843
Project: 145843
Buggy source:
private String serialize(Set roles){
  StringBuffer buffer=new StringBuffer();
  Iterator iterator=roles.iterator();
  while (iterator.hasNext()) {
    String role=(String)iterator.next();
    buffer.append(role);
    if (iterator.hasNext())     buffer.append("String_Node_Str");
  }
  return buffer.toString();
}

Fixed version (ground truth):
private String serialize(Set roles){
  if (null == roles || roles.isEmpty())   return "String_Node_Str";
  StringBuffer buffer=new StringBuffer();
  Iterator iterator=roles.iterator();
  while (iterator.hasNext()) {
    String role=(String)iterator.next();
    buffer.append(role);
    if (iterator.hasNext())     buffer.append("String_Node_Str");
  }
  return buffer.toString();
}
Program: 145844
Project: 145844
Buggy source:
private Set deserialize(String roleString){
  StringTokenizer st=new StringTokenizer(roleString,"String_Node_Str");
  Set roles=new HashSet();
  while (st.hasMoreTokens()) {
    roles.add(st.nextToken());
  }
  return roles;
}

Fixed version (ground truth):
private Set deserialize(String roleString){
  if ("String_Node_Str".equals(roleString))   return new HashSet();
  StringTokenizer st=new StringTokenizer(roleString,"String_Node_Str");
  Set roles=new HashSet();
  while (st.hasMoreTokens()) {
    roles.add(st.nextToken());
  }
  return roles;
}
Program: 145845
Project: 145845
Buggy source:
private List find(PreparedStatement statement){
  ResultSet result=null;
  List snips=new ArrayList();
  try {
    result=statement.executeQuery();
    Snip snip=null;
    while (result.next()) {
      snip=cacheLoad(result);
      snips.add(snip);
    }
  }
 catch (  SQLException e) {
    e.printStackTrace();
  }
 finally {
    ConnectionManager.close(result);
  }
  return snips;
}

Fixed version (ground truth):
private List find(PreparedStatement statement,int count){
  ResultSet result=null;
  List snips=new ArrayList();
  try {
    result=statement.executeQuery();
    Snip snip=null;
    while (result.next() && --count > 0) {
      snip=cacheLoad(result);
      snips.add(snip);
    }
  }
 catch (  SQLException e) {
    e.printStackTrace();
  }
 finally {
    ConnectionManager.close(result);
  }
  return snips;
}