nus-yam/ex-repair huggingface dataset:
Program: 155433
Project: 155433
Buggy source:
@Override public boolean equals(Object obj){
  if (this == obj)   return true;
  if (obj == null)   return false;
  if (getClass() != obj.getClass())   return false;
  PRLine other=(PRLine)obj;
  if (estimatedUnitCost != other.estimatedUnitCost)   return false;
  if (item == null) {
    if (other.item != null)     return false;
  }
 else   if (!item.equals(other.item))   return false;
  if (quantity != other.quantity)   return false;
  return true;
}

Fixed version (ground truth):
@Override public boolean equals(Object obj){
  if (this == obj)   return true;
  if (obj == null)   return false;
  if (getClass() != obj.getClass())   return false;
  PRLine other=(PRLine)obj;
  if (Float.floatToIntBits(estimatedUnitCost) != Float.floatToIntBits(other.estimatedUnitCost))   return false;
  if (item == null) {
    if (other.item != null)     return false;
  }
 else   if (!item.equals(other.item))   return false;
  if (quantity != other.quantity)   return false;
  return true;
}
Program: 155434
Project: 155434
Buggy source:
private long checkNum2(String value){
  long num;
  try {
    num=Long.parseLong(value);
    if (num < 0)     return 0;
  }
 catch (  Exception e) {
    return 0;
  }
  return num;
}

Fixed version (ground truth):
private float checkNum2(String value){
  float num;
  try {
    num=Float.parseFloat(value);
    if (num < 0)     return 0;
  }
 catch (  Exception e) {
    return 0;
  }
  return num;
}
Program: 155435
Project: 155435
Buggy source:
@Override public boolean validate(){
  boolean validItem=item != null && item.validate();
  boolean validPr=purchaseRequest != null;
  boolean validQuantity=quantity > 0;
  return validItem && validPr && validQuantity;
}

Fixed version (ground truth):
@Override public boolean validate(){
  boolean validItem=item != null && item.validate();
  boolean validPr=purchaseRequest != null;
  boolean validQuantity=quantity > 0;
  boolean validEstUnitCost=estimatedUnitCost >= 0;
  return validItem && validPr && validQuantity&& validEstUnitCost;
}
Program: 155437
Project: 155437
Buggy source:
public void setDescription(String description){
  this.description=description;
}

Fixed version (ground truth):
public void setDescription(String description){
  if (description != null)   this.description=description.trim();
}
Program: 155438
Project: 155438
Buggy source:
public Item(String description,ItemCategory itemCategory,Unit unit,ItemStatus itemStatus,ItemCondition itemCondition){
  super();
  this.description=description;
  this.itemCategory=itemCategory;
  this.unit=unit;
  this.itemStatus=itemStatus;
  this.itemCondition=itemCondition;
}

Fixed version (ground truth):
public Item(String description,ItemCategory itemCategory,Unit unit,ItemStatus itemStatus,ItemCondition itemCondition){
  this(description,"String_Node_Str",itemCategory,unit,0.0f,null,null,null,null,itemCondition);
}
Program: 155439
Project: 155439
Buggy source:
public void process(HttpServletRequest request,HttpServletResponse response) throws ServletException, IOException {
  PersonManager pManager=new PersonManagerSession();
  AccountManager aManager=new AccountManagerSession();
  ArrayList<Person> availablePersons=new ArrayList<Person>();
  try {
    List<Person> persons;
    persons=pManager.getAllPersons();
    List<Account> accounts=aManager.getAllAccounts();
    boolean dontAdd=false;
    for (int i=0; i < persons.size(); i++) {
      for (int j=0; j < accounts.size(); j++) {
        if (persons.get(i).getId() == accounts.get(j).getPerson().getId()) {
          dontAdd=true;
        }
      }
      if (!dontAdd) {
        availablePersons.add(persons.get(i));
      }
      dontAdd=false;
    }
  }
 catch (  TransactionException e) {
    e.printStackTrace();
  }
  System.out.println("String_Node_Str" + availablePersons.size());
  request.setAttribute("String_Node_Str",availablePersons);
  RequestDispatcher view=request.getRequestDispatcher("String_Node_Str");
  view.forward(request,response);
}

Fixed version (ground truth):
public void process(HttpServletRequest request,HttpServletResponse response) throws ServletException, IOException {
  PersonManager pManager=new PersonManagerSession();
  AccountManager aManager=new AccountManagerSession();
  ArrayList<Person> availablePersons=new ArrayList<Person>();
  try {
    List<Person> persons;
    persons=pManager.getAllPersons();
    List<Account> accounts=aManager.getAllAccounts();
    boolean dontAdd=false;
    for (int i=0; i < persons.size(); i++) {
      for (int j=0; j < accounts.size(); j++) {
        if (persons.get(i).getId() == accounts.get(j).getPerson().getId()) {
          dontAdd=true;
        }
      }
      if (!dontAdd) {
        availablePersons.add(persons.get(i));
      }
      dontAdd=false;
    }
  }
 catch (  TransactionException e) {
    e.printStackTrace();
  }
  request.setAttribute("String_Node_Str",availablePersons);
  RequestDispatcher view=request.getRequestDispatcher(AccountServlet.CREATE_ACCOUNT_FOR_EXISTING);
  view.forward(request,response);
}
Program: 155440
Project: 155440
Buggy source:
private Action parseAction(HttpServletRequest request){
  String action=(String)request.getParameter(ACCOUNT_ACTION);
  if (action.equalsIgnoreCase(VIEW_OWN_ACCOUNT_ACTION))   return new ViewOwnAccountAction();
  if (action.equalsIgnoreCase(ADD_ACCOUNT_ACTION))   return new AccountCreationAction();
  if (action.equalsIgnoreCase(VIEW_ACCOUNTS_ACTION))   return new AccountsViewAction();
  if (action.equalsIgnoreCase(VIEW_ACCOUNT_ACTION))   return new ViewAccountAction();
  if (action.equalsIgnoreCase(SAVE_ACCOUNT_ACTION))   return new SaveAccountAction();
  if (action.equalsIgnoreCase(SAVE_EDITED_ACCOUNT_ACTION))   return new UpdateAccountAction();
  if (action.equalsIgnoreCase(CREATE_FROM_EXISTING))   return new AccountCreationForExistingEmployeeAction();
  if (action.equalsIgnoreCase(SAVE_FOR_EXISTING))   return new SaveAccountForExistingEmployeeAction();
  return null;
}

Fixed version (ground truth):
private Action parseAction(HttpServletRequest request){
  String action=(String)request.getParameter(ACCOUNT_ACTION);
  if (action == null)   return new AccountsViewAction();
  if (action.equalsIgnoreCase(VIEW_OWN_ACCOUNT_ACTION))   return new ViewOwnAccountAction();
  if (action.equalsIgnoreCase(ADD_ACCOUNT_ACTION))   return new AccountCreationAction();
  if (action.equalsIgnoreCase(VIEW_ACCOUNTS_ACTION))   return new AccountsViewAction();
  if (action.equalsIgnoreCase(VIEW_ACCOUNT_ACTION))   return new ViewAccountAction();
  if (action.equalsIgnoreCase(SAVE_ACCOUNT_ACTION))   return new SaveAccountAction();
  if (action.equalsIgnoreCase(SAVE_EDITED_ACCOUNT_ACTION))   return new UpdateAccountAction();
  if (action.equalsIgnoreCase(SAVE_OWN_EDITED_ACCOUNT_ACTION))   return new UpdateOwnAccountAction();
  if (action.equalsIgnoreCase(CREATE_FROM_EXISTING))   return new AccountCreationForExistingEmployeeAction();
  if (action.equalsIgnoreCase(SAVE_FOR_EXISTING))   return new SaveAccountForExistingEmployeeAction();
  return null;
}
Program: 155442
Project: 155442
Buggy source:
private void logInSuccess(HttpServletRequest request,HttpServletResponse response,String username){
  request.setAttribute("String_Node_Str",username);
  forwardToMenuFrameJsp(request,response,username);
}

Fixed version (ground truth):
private void logInSuccess(HttpServletRequest request,HttpServletResponse response,String username) throws ServletException {
  request.setAttribute("String_Node_Str",username);
  forwardToMenuFrameJsp(request,response,username);
}
Program: 155443
Project: 155443
Buggy source:
private void forwardToMenuFrameJsp(HttpServletRequest request,HttpServletResponse response,String username){
  try {
    HttpSession session=request.getSession();
    if (session.isNew()) {
      session.setAttribute("String_Node_Str",username);
      session.setMaxInactiveInterval(30);
    }
    response.sendRedirect("String_Node_Str");
  }
 catch (  IOException e) {
    e.printStackTrace();
  }
}

Fixed version (ground truth):
private void forwardToMenuFrameJsp(HttpServletRequest request,HttpServletResponse response,String username) throws ServletException {
  try {
    RequestDispatcher view=request.getRequestDispatcher("String_Node_Str");
    HttpSession session=request.getSession();
    if (session.isNew()) {
      request.setAttribute("String_Node_Str",username);
      session.setAttribute("String_Node_Str",username);
      session.setMaxInactiveInterval(30);
    }
    view.forward(request,response);
  }
 catch (  IOException e) {
    e.printStackTrace();
  }
}
Program: 155444
Project: 155444
Buggy source:
protected void doGet(HttpServletRequest request,HttpServletResponse response) throws ServletException, IOException {
  System.out.println("String_Node_Str");
  Cleaner.clean(request);
  request.getRequestDispatcher("String_Node_Str").forward(request,response);
}

Fixed version (ground truth):
protected void doGet(HttpServletRequest request,HttpServletResponse response) throws ServletException, IOException {
  System.out.println("String_Node_Str");
  String username=(String)request.getAttribute("String_Node_Str");
  System.out.println("String_Node_Str" + username);
  Cleaner.clean(request);
  request.setAttribute("String_Node_Str",username);
  request.getRequestDispatcher("String_Node_Str").forward(request,response);
}
Program: 155445
Project: 155445
Buggy source:
protected void doPost(HttpServletRequest request,HttpServletResponse response) throws ServletException, IOException {
  DivisionOfficeManager doManager=new DivisionOfficeManagerSession();
  RequestDispatcher view=request.getRequestDispatcher("String_Node_Str");
  ArrayList<String> buildingName=new ArrayList<String>();
  ArrayList<String> buildingAddress=new ArrayList<String>();
  List<Building> buildings=new ArrayList<Building>();
  try {
    buildings=doManager.getAllBuildings();
  }
 catch (  TransactionException e) {
    e.printStackTrace();
  }
  for (  Building b : buildings) {
    buildingName.add(b.getBuildingName());
    buildingAddress.add(b.getBuildingAddress());
  }
  System.out.println("String_Node_Str");
  request.setAttribute("String_Node_Str",buildingName);
  request.setAttribute("String_Node_Str",buildingAddress);
  view.forward(request,response);
}

Fixed version (ground truth):
protected void doPost(HttpServletRequest request,HttpServletResponse response) throws ServletException, IOException {
  DivisionOfficeManager doManager=new DivisionOfficeManagerSession();
  RequestDispatcher view=request.getRequestDispatcher("String_Node_Str");
  List<Building> buildings=new ArrayList<Building>();
  try {
    buildings=doManager.getAllBuildings();
  }
 catch (  TransactionException e) {
    e.printStackTrace();
  }
  request.setAttribute("String_Node_Str",buildings);
  view.forward(request,response);
}
Program: 155448
Project: 155448
Buggy source:
/** 
 * @see HttpServlet#HttpServlet()
 */
public ViewWorkInformation(){
  super();
}

Fixed version (ground truth):
public ViewWorkInformation(){
  super();
}
Program: 155449
Project: 155449
Buggy source:
/** 
 * @see HttpServlet#doGet(HttpServletRequest request,HttpServletResponse response)
 */
protected void doGet(HttpServletRequest request,HttpServletResponse response) throws ServletException, IOException {
}

Fixed version (ground truth):
protected void doGet(HttpServletRequest request,HttpServletResponse response) throws ServletException, IOException {
}
Program: 155451
Project: 155451
Buggy source:
/** 
 * @see HttpServlet#doGet(HttpServletRequest request,HttpServletResponse response)
 */
protected void doGet(HttpServletRequest request,HttpServletResponse response) throws ServletException, IOException {
}

Fixed version (ground truth):
protected void doGet(HttpServletRequest request,HttpServletResponse response) throws ServletException, IOException {
}
Program: 155453
Project: 155453
Buggy source:
/** 
 * @see HttpServlet#doPost(HttpServletRequest request,HttpServletResponse response)
 */
protected void doPost(HttpServletRequest request,HttpServletResponse response) throws ServletException, IOException {
  AccountManager aManager=new AccountManagerSession();
  PersonManager pManager=new PersonManagerSession();
  ArrayList<String> userName=new ArrayList<String>();
  ArrayList<String> acctType=new ArrayList<String>();
  ArrayList<String> name=new ArrayList<String>();
  try {
    List<Account> accounts=aManager.getAllAccounts();
    for (int i=0; i < accounts.size(); i++) {
      userName.add(accounts.get(i).getUsername());
      acctType.add(accounts.get(i).getAccountType());
      name.add(pManager.getPerson(accounts.get(i).getPersonID()).getName());
    }
  }
 catch (  org.hibernate.TransactionException e) {
    e.printStackTrace();
  }
catch (  TransactionException e) {
    e.printStackTrace();
  }
  request.setAttribute("String_Node_Str",userName);
  request.setAttribute("String_Node_Str",acctType);
  request.setAttribute("String_Node_Str",name);
  request.setAttribute("String_Node_Str","String_Node_Str" + userName.size());
  RequestDispatcher view=request.getRequestDispatcher("String_Node_Str");
  view.forward(request,response);
}

Fixed version (ground truth):
/** 
 * @see HttpServlet#doPost(HttpServletRequest request,HttpServletResponse response)
 */
protected void doPost(HttpServletRequest request,HttpServletResponse response) throws ServletException, IOException {
  AccountManager aManager=new AccountManagerSession();
  PersonManager pManager=new PersonManagerSession();
  ArrayList<String> userName=new ArrayList<String>();
  ArrayList<String> acctType=new ArrayList<String>();
  ArrayList<String> name=new ArrayList<String>();
  try {
    List<Account> accounts=aManager.getAllAccounts();
    for (int i=0; i < accounts.size(); i++) {
      userName.add(accounts.get(i).getUsername());
      name.add(accounts.get(i).getPerson().getName());
    }
  }
 catch (  org.hibernate.TransactionException e) {
    e.printStackTrace();
  }
catch (  TransactionException e) {
    e.printStackTrace();
  }
  request.setAttribute("String_Node_Str",userName);
  request.setAttribute("String_Node_Str",acctType);
  request.setAttribute("String_Node_Str",name);
  request.setAttribute("String_Node_Str","String_Node_Str" + userName.size());
  RequestDispatcher view=request.getRequestDispatcher("String_Node_Str");
  view.forward(request,response);
}
Program: 155457
Project: 155457
Buggy source:
@Override protected void doPost(HttpServletRequest req,HttpServletResponse resp) throws ServletException, IOException {
  String longUrl=req.getParameter("String_Node_Str");
  log.info("String_Node_Str" + longUrl);
  ShortenerService service=new ShortenerService();
  ShortUrl shortUrl=service.shorten(longUrl);
  req.getSession().setAttribute("String_Node_Str",shortUrl);
  log.info("String_Node_Str" + shortUrl);
  resp.sendRedirect("String_Node_Str");
}

Fixed version (ground truth):
@Override protected void doPost(HttpServletRequest req,HttpServletResponse resp) throws ServletException, IOException {
  String longUrl=req.getParameter("String_Node_Str");
  log.info("String_Node_Str" + longUrl);
  ShortenerService service=new ShortenerService();
  ShortUrl shortUrl=service.shorten(longUrl);
  req.getSession().setAttribute("String_Node_Str",shortUrl.toString());
  resp.sendRedirect("String_Node_Str");
}
Program: 155458
Project: 155458
Buggy source:
public void shutdown(){
}

Fixed version (ground truth):
public void shutdown(){
  serverIdArray=null;
}
Program: 155459
Project: 155459
Buggy source:
/** 
 * Build the server ID byte array that will be prepended in generated UIDs. Once built, the value is cached for the duration of the JVM lifespan.
 * @return the server ID.
 */
public byte[] buildServerIdArray(){
  if (serverIdArray == null) {
    try {
      serverIdArray=serverId.substring(0,Math.min(serverId.length(),MAX_SERVER_ID_LENGTH)).getBytes("String_Node_Str");
    }
 catch (    Exception ex) {
      log.warn("String_Node_Str");
      try {
        serverIdArray=InetAddress.getLocalHost().getHostAddress().getBytes("String_Node_Str");
      }
 catch (      Exception ex2) {
        final String unknownServerId="String_Node_Str";
        log.warn("String_Node_Str" + unknownServerId + "String_Node_Str");
        serverIdArray=unknownServerId.getBytes();
      }
    }
    if (serverIdArray.length > MAX_SERVER_ID_LENGTH) {
      byte[] truncatedServerId=new byte[MAX_SERVER_ID_LENGTH];
      System.arraycopy(serverIdArray,0,truncatedServerId,0,MAX_SERVER_ID_LENGTH);
      serverIdArray=truncatedServerId;
    }
    String serverIdArrayAsString=new String(serverIdArray);
    if (serverId == null)     serverId=serverIdArrayAsString;
    log.info("String_Node_Str" + serverIdArrayAsString + "String_Node_Str");
  }
  return serverIdArray;
}

Fixed version (ground truth):
/** 
 * Build the server ID byte array that will be prepended in generated UIDs. Once built, the value is cached for the duration of the JVM lifespan.
 * @return the server ID.
 */
public synchronized byte[] buildServerIdArray(){
  if (serverIdArray == null) {
    try {
      serverIdArray=serverId.substring(0,Math.min(serverId.length(),MAX_SERVER_ID_LENGTH)).getBytes("String_Node_Str");
    }
 catch (    Exception ex) {
      log.warn("String_Node_Str");
      try {
        serverIdArray=InetAddress.getLocalHost().getHostAddress().getBytes("String_Node_Str");
      }
 catch (      Exception ex2) {
        final String unknownServerId="String_Node_Str";
        log.warn("String_Node_Str" + unknownServerId + "String_Node_Str");
        serverIdArray=unknownServerId.getBytes();
      }
    }
    if (serverIdArray.length > MAX_SERVER_ID_LENGTH) {
      byte[] truncatedServerId=new byte[MAX_SERVER_ID_LENGTH];
      System.arraycopy(serverIdArray,0,truncatedServerId,0,MAX_SERVER_ID_LENGTH);
      serverIdArray=truncatedServerId;
    }
    String serverIdArrayAsString=new String(serverIdArray);
    if (serverId == null)     serverId=serverIdArrayAsString;
    log.info("String_Node_Str" + serverIdArrayAsString + "String_Node_Str");
  }
  return serverIdArray;
}
Program: 155460
Project: 155460
Buggy source:
/** 
 * Clear services references. Called at the end of the shutdown procedure.
 */
protected static synchronized void clear(){
  transactionManager=null;
  transactionSynchronizationRegistry=null;
  configuration=null;
  journal=null;
  taskScheduler=null;
  resourceLoader=null;
  recoverer=null;
  executor=null;
}

Fixed version (ground truth):
/** 
 * Clear services references. Called at the end of the shutdown procedure.
 */
protected synchronized static void clear(){
  transactionManager=null;
  transactionSynchronizationRegistry=null;
  configuration=null;
  journal=null;
  taskScheduler=null;
  resourceLoader=null;
  recoverer=null;
  executor=null;
}
Program: 155461
Project: 155461
Buggy source:
/** 
 * <p>Swap the active and the passive journal files so that the active one becomes passive and the passive one becomes active.</p> List of actions taken by this method: <ul> <li>copy dangling COMMITTING records to the passive log file.</li> <li>update header timestamp of passive log file (makes it become active).</li> <li>do a force on passive log file. It is now the active file.</li> <li>switch references of active/passive files.</li> </ul>
 * @throws java.io.IOException in case of disk IO failure.
 */
private void swapJournalFiles() throws IOException {
  if (log.isDebugEnabled())   log.debug("String_Node_Str" + getPassiveTransactionLogAppender());
  TransactionLogAppender passiveTla=getPassiveTransactionLogAppender();
  passiveTla.getHeader().rewind();
  copyDanglingRecords(activeTla,passiveTla);
  passiveTla.getHeader().setTimestamp(MonotonicClock.currentTimeMillis());
  passiveTla.force();
  if (activeTla == tla1) {
    activeTla=tla2;
  }
 else {
    activeTla=tla1;
  }
  if (log.isDebugEnabled())   log.debug("String_Node_Str");
}

Fixed version (ground truth):
/** 
 * <p>Swap the active and the passive journal files so that the active one becomes passive and the passive one becomes active.</p> List of actions taken by this method: <ul> <li>copy dangling COMMITTING records to the passive log file.</li> <li>update header timestamp of passive log file (makes it become active).</li> <li>do a force on passive log file. It is now the active file.</li> <li>switch references of active/passive files.</li> </ul>
 * @throws java.io.IOException in case of disk IO failure.
 */
private synchronized void swapJournalFiles() throws IOException {
  if (log.isDebugEnabled())   log.debug("String_Node_Str" + getPassiveTransactionLogAppender());
  TransactionLogAppender passiveTla=getPassiveTransactionLogAppender();
  passiveTla.getHeader().rewind();
  copyDanglingRecords(activeTla,passiveTla);
  passiveTla.getHeader().setTimestamp(MonotonicClock.currentTimeMillis());
  passiveTla.force();
  if (activeTla == tla1) {
    activeTla=tla2;
  }
 else {
    activeTla=tla1;
  }
  if (log.isDebugEnabled())   log.debug("String_Node_Str");
}
Program: 155462
Project: 155462
Buggy source:
/** 
 * @return the TransactionFileAppender of the passive journal file.
 */
private TransactionLogAppender getPassiveTransactionLogAppender(){
  if (tla1 == activeTla)   return tla2;
  return tla1;
}

Fixed version (ground truth):
/** 
 * @return the TransactionFileAppender of the passive journal file.
 */
private synchronized TransactionLogAppender getPassiveTransactionLogAppender(){
  if (tla1 == activeTla)   return tla2;
  return tla1;
}
Program: 155463
Project: 155463
Buggy source:
/** 
 * Processes the enlisted elements with the given force command and notifies any waiting threads on success or failure.
 * @param forceCommand the command to run prior to notifying the threads.
 * @param elements     the elements that are processed by command (and are the base for notification).
 * @throws Exception the exception thrown by the command if it failed.
 */
public void processEnlisted(Callable forceCommand,Collection<ForceableElement> elements) throws Exception {
  forceLock.lock();
  try {
    try {
      forceCommand.call();
      recordSuccess(elements);
    }
 catch (    Exception e) {
      recordFailures(elements);
      throw e;
    }
  }
  finally {
    performedForce.signalAll();
    forceLock.unlock();
  }
}

Fixed version (ground truth):
/** 
 * Processes the enlisted elements with the given force command and notifies any waiting threads on success or failure.
 * @param forceCommand the command to run prior to notifying the threads.
 * @param elements     the elements that are processed by command (and are the base for notification).
 * @throws Exception the exception thrown by the command if it failed.
 */
public void processEnlisted(Callable forceCommand,Collection<ForceableElement> elements) throws Exception {
  forceLock.lock();
  try {
    try {
      forceCommand.call();
      recordSuccess(elements);
    }
 catch (    Exception e) {
      recordFailures(elements);
      throw e;
    }
 finally {
      performedForce.signalAll();
    }
  }
  finally {
    forceLock.unlock();
  }
}
Program: 155464
Project: 155464
Buggy source:
/** 
 * {@inheritDoc}
 */
@Override public synchronized void open() throws IOException {
  journalFilePath=getJournalFilePath();
  long journalSize=TransactionManagerServices.getConfiguration().getMaxLogSizeInMb() * 1024 * 1024* 3;
  if (log.isDebugEnabled()) {
    log.debug("String_Node_Str",journalFilePath,journalSize / 1024 / 1024);
  }
  if (log.isTraceEnabled())   log.trace("String_Node_Str");
  close();
  this.journalFile=new NioJournalFile(journalFilePath,journalSize);
  log.info("String_Node_Str",journalFilePath);
  if (log.isDebugEnabled())   log.debug("String_Node_Str",journalFilePath);
  for (  NioJournalFileRecord fileRecord : journalFile.readAll(false)) {
    ByteBuffer buffer=fileRecord.getPayload();
    try {
      buffer.mark();
      NioJournalRecord record=new NioJournalRecord(buffer,fileRecord.isValid());
      if (!fileRecord.isValid()) {
        log.error("String_Node_Str" + "String_Node_Str",record,journalFilePath);
      }
 else       trackedTransactions.track(record);
    }
 catch (    Exception e) {
      buffer.reset();
      String contentString=NioJournalFileRecord.bufferToString(buffer);
      log.error("String_Node_Str" + "String_Node_Str",contentString,journalFilePath);
    }
  }
  log.info("String_Node_Str",trackedTransactions.size());
  trackedTransactions.purgeTransactionsExceedingLifetime();
  journalWritingThread=new NioJournalWritingThread(trackedTransactions,journalFile,skipForce ? null : forceSynchronizer);
  log.info("String_Node_Str",journalFilePath);
}

Fixed version (ground truth):
/** 
 * {@inheritDoc}
 */
@Override public synchronized void open() throws IOException {
  journalFilePath=getJournalFilePath();
  long journalSize=TransactionManagerServices.getConfiguration().getMaxLogSizeInMb() * 1024L * 1024L* 3L;
  if (log.isDebugEnabled()) {
    log.debug("String_Node_Str",journalFilePath,journalSize / 1024 / 1024);
  }
  if (log.isTraceEnabled())   log.trace("String_Node_Str");
  close();
  this.journalFile=new NioJournalFile(journalFilePath,journalSize);
  log.info("String_Node_Str",journalFilePath);
  if (log.isDebugEnabled())   log.debug("String_Node_Str",journalFilePath);
  for (  NioJournalFileRecord fileRecord : journalFile.readAll(false)) {
    ByteBuffer buffer=fileRecord.getPayload();
    try {
      buffer.mark();
      NioJournalRecord record=new NioJournalRecord(buffer,fileRecord.isValid());
      if (!fileRecord.isValid()) {
        log.error("String_Node_Str" + "String_Node_Str",record,journalFilePath);
      }
 else       trackedTransactions.track(record);
    }
 catch (    Exception e) {
      buffer.reset();
      String contentString=NioJournalFileRecord.bufferToString(buffer);
      log.error("String_Node_Str" + "String_Node_Str",contentString,journalFilePath);
    }
  }
  log.info("String_Node_Str",trackedTransactions.size());
  trackedTransactions.purgeTransactionsExceedingLifetime();
  journalWritingThread=new NioJournalWritingThread(trackedTransactions,journalFile,skipForce ? null : forceSynchronizer);
  log.info("String_Node_Str",journalFilePath);
}
Program: 155465
Project: 155465
Buggy source:
public NioJournalFile(File file,long initialJournalSize) throws IOException {
  this.file=file;
  raf=new RandomAccessFile(file,"String_Node_Str");
  fileChannel=raf.getChannel();
  lock=fileChannel.lock();
  final boolean createHeader=raf.length() == 0;
  try {
    readJournalHeader();
  }
 catch (  IOException e) {
    log.error("String_Node_Str" + file + "String_Node_Str",e);
    close();
    throw e;
  }
  this.journalSize=Math.max(initialJournalSize,raf.length());
  growJournal(this.journalSize);
  if (createHeader)   writeJournalHeader();
 else {
    NioJournalFileIterable it=(NioJournalFileIterable)readRecords(delimiter,fileChannel,false);
    long position=it.findPositionAfterLastRecord();
    fileChannel.position(Math.max(FIXED_HEADER_SIZE,position));
  }
}

Fixed version (ground truth):
public NioJournalFile(File file,long initialJournalSize) throws IOException {
  this.file=file;
  raf=new RandomAccessFile(file,"String_Node_Str");
  fileChannel=raf.getChannel();
  lock=fileChannel.lock();
  final boolean createHeader=raf.length() == 0;
  try {
    readJournalHeader();
  }
 catch (  IOException e) {
    log.error("String_Node_Str" + file + "String_Node_Str",e);
    close();
    throw e;
  }
  this.journalSize.set(Math.max(initialJournalSize,raf.length()));
  growJournal(this.journalSize.get());
  if (createHeader)   writeJournalHeader();
 else {
    NioJournalFileIterable it=(NioJournalFileIterable)readRecords(delimiter,fileChannel,false);
    long position=it.findPositionAfterLastRecord();
    fileChannel.position(Math.max(FIXED_HEADER_SIZE,position));
  }
}
Program: 155466
Project: 155466
Buggy source:
public synchronized void growJournal(long newSize) throws IOException {
  if (newSize >= journalSize) {
    raf.setLength(newSize);
    journalSize=newSize;
  }
}

Fixed version (ground truth):
public synchronized void growJournal(long newSize) throws IOException {
  if (newSize >= journalSize.get()) {
    raf.setLength(newSize);
    journalSize.set(newSize);
  }
}
Program: 155467
Project: 155467
Buggy source:
public synchronized long getSize(){
  return journalSize;
}

Fixed version (ground truth):
public synchronized long getSize(){
  return journalSize.get();
}
Program: 155468
Project: 155468
Buggy source:
/** 
 * Closes the journal.
 * @throws IOException in case of the operation failed.
 */
public synchronized void close() throws IOException {
  try {
    if (fileChannel != null) {
      force();
      fileChannel.close();
    }
  }
  finally {
    fileChannel=null;
    lock=null;
  }
}

Fixed version (ground truth):
/** 
 * Closes the journal.
 * @throws IOException in case of the operation failed.
 */
public synchronized void close() throws IOException {
  try {
    if (fileChannel != null) {
      force();
      try {
        lock.release();
      }
  finally {
        fileChannel.close();
      }
    }
  }
  finally {
    fileChannel=null;
    lock=null;
  }
}
Program: 155469
Project: 155469
Buggy source:
/** 
 * Returns the remaining capacity in this journal until the rollover happens.
 * @return the remaining capacity in this journal until the rollover happens.
 * @throws IOException in case of the operation failed.
 */
public long remainingCapacity() throws IOException {
  return Math.max(0,journalSize - fileChannel.position());
}

Fixed version (ground truth):
/** 
 * Returns the remaining capacity in this journal until the rollover happens.
 * @return the remaining capacity in this journal until the rollover happens.
 * @throws IOException in case of the operation failed.
 */
public long remainingCapacity() throws IOException {
  return Math.max(0,journalSize.get() - fileChannel.position());
}
Program: 155470
Project: 155470
Buggy source:
private void consumePreviousRecord(){
  if (buffer.hasRemaining()) {
    final int limit=buffer.limit(), cap=buffer.capacity();
    buffer.limit(cap).position(Math.min(cap,limit + NioJournalFileRecord.RECORD_TRAILER_SIZE));
  }
}

Fixed version (ground truth):
private void consumePreviousRecord(){
  if (buffer.hasRemaining()) {
    final int limit=buffer.limit(), cap=buffer.capacity();
    buffer.limit(cap).position(Math.min(cap,limit + RECORD_TRAILER_SIZE));
  }
}
Program: 155471
Project: 155471
Buggy source:
@Override public boolean hasNext(){
  while (nextEntry == null && readNextEntry()) {
    nextEntry=new NioJournalFileRecord(delimiter,buffer);
    readEntries++;
    if (buffer.getInt(buffer.position() + reverseCrc32Offset) != nextEntry.calculateCrc32()) {
      if (readInvalid) {
        log.warn("String_Node_Str",nextEntry);
        nextEntry.markInvalid();
      }
 else {
        log.warn("String_Node_Str",nextEntry);
        nextEntry=null;
      }
      brokenEntries++;
    }
 else {
      positionAfterLastRecord=bufferPosition + buffer.limit() + NioJournalFileRecord.RECORD_TRAILER_SIZE;
    }
  }
  return nextEntry != null;
}

Fixed version (ground truth):
@Override public boolean hasNext(){
  while (nextEntry == null && readNextEntry()) {
    nextEntry=new NioJournalFileRecord(delimiter,buffer);
    readEntries++;
    if (buffer.getInt(buffer.position() + reverseCrc32Offset) != nextEntry.calculateCrc32()) {
      if (readInvalid) {
        log.warn("String_Node_Str",nextEntry);
        nextEntry.markInvalid();
      }
 else {
        log.warn("String_Node_Str",nextEntry);
        nextEntry=null;
      }
      brokenEntries++;
    }
 else {
      positionAfterLastRecord=bufferPosition + buffer.limit() + RECORD_TRAILER_SIZE;
    }
  }
  return nextEntry != null;
}
Program: 155472
Project: 155472
Buggy source:
private boolean readNextEntry(){
  consumePreviousRecord();
  while (true) {
    buffer.limit(buffer.capacity());
    int recordLength=NioJournalFileRecord.findNextRecord(buffer,delimiter);
    NioJournalFileRecord.ReadStatus readStatus=NioJournalFileRecord.ReadStatus.decode(recordLength);
switch (readStatus) {
case foundPartialRecord:
      if (buffer.position() == 0) {
        int newSize=buffer.capacity() + 4 * 1024;
        if (log.isDebugEnabled()) {
          log.debug("String_Node_Str",newSize);
        }
        buffer=ByteBuffer.allocate(newSize).put(buffer);
      }
 else       if (buffer.hasRemaining()) {
        if (log.isTraceEnabled()) {
          log.trace("String_Node_Str" + "String_Node_Str",buffer.remaining());
        }
        buffer.compact();
      }
    break;
case noHeaderInBuffer:
  buffer.clear();
break;
}
if (readStatus != NioJournalFileRecord.ReadStatus.readOk) {
try {
bufferPosition=position - buffer.position();
int readBytes=fileChannel.read(buffer,position);
if (readBytes == -1) break;
position+=readBytes;
buffer.flip();
}
 catch (IOException e) {
throw new RuntimeException(e);
}
}
 else {
buffer.limit(buffer.position() + recordLength);
return true;
}
}
return false;
}

Fixed version (ground truth):
private boolean readNextEntry(){
  consumePreviousRecord();
  while (true) {
    buffer.limit(buffer.capacity());
    int recordLength=NioJournalFileRecord.findNextRecord(buffer,delimiter);
    NioJournalFileRecord.ReadStatus readStatus=NioJournalFileRecord.ReadStatus.decode(recordLength);
switch (readStatus) {
case FoundPartialRecord:
      if (buffer.position() == 0) {
        int newSize=buffer.capacity() + 4 * 1024;
        if (log.isDebugEnabled()) {
          log.debug("String_Node_Str",newSize);
        }
        buffer=ByteBuffer.allocate(newSize).put(buffer);
      }
 else       if (buffer.hasRemaining()) {
        if (log.isTraceEnabled()) {
          log.trace("String_Node_Str" + "String_Node_Str",buffer.remaining());
        }
        buffer.compact();
      }
    break;
case NoHeaderInBuffer:
  buffer.clear();
break;
}
if (readStatus != NioJournalFileRecord.ReadStatus.ReadOk) {
try {
bufferPosition=position - buffer.position();
int readBytes=fileChannel.read(buffer,position);
if (readBytes == -1) break;
position+=readBytes;
buffer.flip();
}
 catch (IOException e) {
throw new RuntimeException(e);
}
}
 else {
buffer.limit(buffer.position() + recordLength);
return true;
}
}
return false;
}
Program: 155473
Project: 155473
Buggy source:
public void testRestartWithLoader() throws Exception {
  for (int i=0; i < 3; i++) {
    TransactionManagerServices.getConfiguration().setResourceConfigurationFilename(getClass().getResource("String_Node_Str").getFile());
    BitronixTransactionManager tm=TransactionManagerServices.getTransactionManager();
    assertEquals("String_Node_Str" + (i + 1),1,ResourceRegistrar.getResourcesUniqueNames().size());
    tm.shutdown();
    assertEquals("String_Node_Str" + (i + 1),0,ResourceRegistrar.getResourcesUniqueNames().size());
  }
}

Fixed version (ground truth):
public void testRestartWithLoader() throws Exception {
  for (int i=0; i < 3; i++) {
    String configFile=new File(getClass().getResource("String_Node_Str").toURI()).getPath();
    TransactionManagerServices.getConfiguration().setResourceConfigurationFilename(configFile);
    BitronixTransactionManager tm=TransactionManagerServices.getTransactionManager();
    assertEquals("String_Node_Str" + (i + 1),1,ResourceRegistrar.getResourcesUniqueNames().size());
    tm.shutdown();
    assertEquals("String_Node_Str" + (i + 1),0,ResourceRegistrar.getResourcesUniqueNames().size());
  }
}
Program: 155474
Project: 155474
Buggy source:
private static String evaluate(Properties properties,String value){
  String result=value;
  int startIndex=value.indexOf('$');
  if (startIndex > -1 && value.charAt(startIndex + 1) == '{') {
    int endIndex=value.indexOf('}');
    if (startIndex + 2 == endIndex)     throw new IllegalArgumentException("String_Node_Str");
    if (endIndex == -1)     throw new IllegalArgumentException("String_Node_Str" + value.substring(startIndex + 2));
    String subPropertyKey=value.substring(startIndex + 2,endIndex);
    String subPropertyValue=getString(properties,subPropertyKey,null);
    result=result.substring(0,startIndex) + subPropertyValue + result.substring(endIndex + 1);
    return evaluate(properties,result);
  }
  return result;
}

Fixed version (ground truth):
private static String evaluate(Properties properties,String value){
  String result=value;
  int startIndex=value.indexOf('$');
  if (startIndex > -1 && value.length() > startIndex + 1 && value.charAt(startIndex + 1) == '{') {
    int endIndex=value.indexOf('}');
    if (startIndex + 2 == endIndex)     throw new IllegalArgumentException("String_Node_Str");
    if (endIndex == -1)     throw new IllegalArgumentException("String_Node_Str" + value.substring(startIndex + 2));
    String subPropertyKey=value.substring(startIndex + 2,endIndex);
    String subPropertyValue=getString(properties,subPropertyKey,null);
    result=result.substring(0,startIndex) + subPropertyValue + result.substring(endIndex + 1);
    return evaluate(properties,result);
  }
  return result;
}
Program: 155476
Project: 155476
Buggy source:
public void rollback(Xid xid) throws XAException {
  if (xid == null)   throw new BitronixXAException("String_Node_Str",XAException.XAER_INVAL);
  if (state == NO_TX) {
    throw new BitronixXAException("String_Node_Str" + xid,XAException.XAER_PROTO);
  }
 else   if (state == STARTED) {
    throw new BitronixXAException("String_Node_Str" + xid,XAException.XAER_PROTO);
  }
 else   if (state == ENDED) {
    if (this.xid.equals(xid)) {
      if (log.isDebugEnabled())       log.debug("String_Node_Str" + xlatedState() + "String_Node_Str"+ xid);
    }
 else     throw new BitronixXAException("String_Node_Str" + this.xid + "String_Node_Str"+ xid,XAException.XAER_PROTO);
  }
 else   if (state == PREPARED) {
    this.state=NO_TX;
    throw new BitronixXAException("String_Node_Str" + this.xid,XAException.XA_HEURCOM);
  }
  try {
    connection.rollback();
    this.state=NO_TX;
    this.xid=null;
  }
 catch (  SQLException ex) {
    throw new BitronixXAException("String_Node_Str",XAException.XAER_RMERR,ex);
  }
  try {
    if (autocommitActiveBeforeStart) {
      if (log.isDebugEnabled())       log.debug("String_Node_Str");
      connection.setAutoCommit(true);
    }
  }
 catch (  SQLException ex) {
    throw new BitronixXAException("String_Node_Str",XAException.XAER_RMERR);
  }
}

Fixed version (ground truth):
public void rollback(Xid xid) throws XAException {
  if (xid == null)   throw new BitronixXAException("String_Node_Str",XAException.XAER_INVAL);
  if (state == NO_TX) {
    throw new BitronixXAException("String_Node_Str" + xid,XAException.XAER_PROTO);
  }
 else   if (state == STARTED) {
    throw new BitronixXAException("String_Node_Str" + xid,XAException.XAER_PROTO);
  }
 else   if (state == ENDED) {
    if (this.xid.equals(xid)) {
      if (log.isDebugEnabled())       log.debug("String_Node_Str" + xlatedState() + "String_Node_Str"+ xid);
    }
 else     throw new BitronixXAException("String_Node_Str" + this.xid + "String_Node_Str"+ xid,XAException.XAER_PROTO);
  }
 else   if (state == PREPARED) {
    this.state=NO_TX;
    throw new BitronixXAException("String_Node_Str" + this.xid,XAException.XA_HEURCOM);
  }
  try {
    connection.rollback();
  }
 catch (  SQLException ex) {
    throw new BitronixXAException("String_Node_Str",XAException.XAER_RMERR,ex);
  }
 finally {
    this.state=NO_TX;
    this.xid=null;
  }
  try {
    if (autocommitActiveBeforeStart) {
      if (log.isDebugEnabled())       log.debug("String_Node_Str");
      connection.setAutoCommit(true);
    }
  }
 catch (  SQLException ex) {
    throw new BitronixXAException("String_Node_Str",XAException.XAER_RMERR);
  }
}
Program: 155477
Project: 155477
Buggy source:
public void rollback(Xid xid) throws XAException {
  if (xid == null)   throw new BitronixXAException("String_Node_Str",XAException.XAER_INVAL);
  if (state == NO_TX) {
    throw new BitronixXAException("String_Node_Str" + xid,XAException.XAER_PROTO);
  }
 else   if (state == STARTED) {
    throw new BitronixXAException("String_Node_Str" + xid,XAException.XAER_PROTO);
  }
 else   if (state == ENDED) {
    if (this.xid.equals(xid)) {
      if (log.isDebugEnabled())       log.debug("String_Node_Str" + xlatedState() + "String_Node_Str"+ xid);
    }
 else     throw new BitronixXAException("String_Node_Str" + this.xid + "String_Node_Str"+ xid,XAException.XAER_PROTO);
  }
 else   if (state == PREPARED) {
    this.state=NO_TX;
    throw new BitronixXAException("String_Node_Str" + this.xid,XAException.XA_HEURCOM);
  }
  try {
    session.rollback();
    this.state=NO_TX;
    this.xid=null;
  }
 catch (  JMSException ex) {
    throw new BitronixXAException("String_Node_Str",XAException.XAER_RMERR,ex);
  }
}

Fixed version (ground truth):
public void rollback(Xid xid) throws XAException {
  if (xid == null)   throw new BitronixXAException("String_Node_Str",XAException.XAER_INVAL);
  if (state == NO_TX) {
    throw new BitronixXAException("String_Node_Str" + xid,XAException.XAER_PROTO);
  }
 else   if (state == STARTED) {
    throw new BitronixXAException("String_Node_Str" + xid,XAException.XAER_PROTO);
  }
 else   if (state == ENDED) {
    if (this.xid.equals(xid)) {
      if (log.isDebugEnabled())       log.debug("String_Node_Str" + xlatedState() + "String_Node_Str"+ xid);
    }
 else     throw new BitronixXAException("String_Node_Str" + this.xid + "String_Node_Str"+ xid,XAException.XAER_PROTO);
  }
 else   if (state == PREPARED) {
    this.state=NO_TX;
    throw new BitronixXAException("String_Node_Str" + this.xid,XAException.XA_HEURCOM);
  }
  try {
    session.rollback();
  }
 catch (  JMSException ex) {
    throw new BitronixXAException("String_Node_Str",XAException.XAER_RMERR,ex);
  }
 finally {
    this.state=NO_TX;
    this.xid=null;
  }
}
Program: 155478
Project: 155478
Buggy source:
private synchronized void detectJdbcVersion(Connection connection){
  if (jdbcVersionDetected > 0)   return;
  try {
    isValidMethod=connection.getClass().getMethod("String_Node_Str",new Class[]{Integer.TYPE});
    isValidMethod.invoke(connection,new Object[]{new Integer(DETECTION_TIMEOUT)});
    jdbcVersionDetected=4;
    if (!poolingDataSource.isEnableJdbc4ConnectionTest()) {
      if (log.isDebugEnabled())       log.debug("String_Node_Str");
    }
  }
 catch (  Exception ex) {
    jdbcVersionDetected=3;
  }
  if (log.isDebugEnabled())   log.debug("String_Node_Str" + connection.getClass() + "String_Node_Str"+ jdbcVersionDetected+ "String_Node_Str");
}

Fixed version (ground truth):
private synchronized void detectJdbcVersion(Connection connection){
  if (jdbcVersionDetected > 0)   return;
  try {
    isValidMethod=connection.getClass().getMethod("String_Node_Str",new Class[]{Integer.TYPE});
    isValidMethod.invoke(connection,new Object[]{new Integer(DETECTION_TIMEOUT)});
    jdbcVersionDetected=4;
    if (!poolingDataSource.isEnableJdbc4ConnectionTest()) {
      if (log.isDebugEnabled())       log.debug("String_Node_Str");
    }
  }
 catch (  Exception ex) {
    jdbcVersionDetected=3;
  }
catch (  AbstractMethodError er) {
    jdbcVersionDetected=3;
  }
  if (log.isDebugEnabled())   log.debug("String_Node_Str" + connection.getClass() + "String_Node_Str"+ jdbcVersionDetected+ "String_Node_Str");
}
Program: 155479
Project: 155479
Buggy source:
private void applyLocalAutoCommit() throws SQLException {
  String localAutoCommit=getPoolingDataSource().getLocalAutoCommit();
  if (localAutoCommit != null) {
    if (localAutoCommit.equalsIgnoreCase("String_Node_Str")) {
      if (log.isDebugEnabled())       log.debug("String_Node_Str");
      connection.setAutoCommit(true);
    }
 else     if (localAutoCommit.equalsIgnoreCase("String_Node_Str")) {
      if (log.isDebugEnabled())       log.debug("String_Node_Str");
      connection.setAutoCommit(false);
    }
 else {
      if (log.isDebugEnabled())       log.warn("String_Node_Str" + localAutoCommit + "String_Node_Str");
    }
  }
}

Fixed version (ground truth):
private void applyLocalAutoCommit() throws SQLException {
  String localAutoCommit=getPoolingDataSource().getLocalAutoCommit();
  if (localAutoCommit != null) {
    if (localAutoCommit.equalsIgnoreCase("String_Node_Str")) {
      if (log.isDebugEnabled())       log.debug("String_Node_Str");
      connection.setAutoCommit(true);
    }
 else     if (localAutoCommit.equalsIgnoreCase("String_Node_Str")) {
      if (log.isDebugEnabled())       log.debug("String_Node_Str");
      connection.setAutoCommit(false);
    }
 else {
      log.warn("String_Node_Str" + localAutoCommit + "String_Node_Str");
    }
  }
}
Program: 155480
Project: 155480
Buggy source:
public BitronixContext(){
  userTransactionName=TransactionManagerServices.getConfiguration().getJndiUserTransactionName();
  if (userTransactionName == null)   userTransactionName=DEFAULT_USER_TRANSACTION_NAME;
  if (log.isDebugEnabled())   log.debug("String_Node_Str" + userTransactionName + "String_Node_Str");
  userTransactionName=TransactionManagerServices.getConfiguration().getJndiTransactionSynchronizationRegistryName();
  if (synchronizationRegistryName == null)   synchronizationRegistryName=DEFAULT_SYNCHRONIZATION_REGISTRY_NAME;
  if (log.isDebugEnabled())   log.debug("String_Node_Str" + synchronizationRegistryName + "String_Node_Str");
}

Fixed version (ground truth):
public BitronixContext(){
  userTransactionName=TransactionManagerServices.getConfiguration().getJndiUserTransactionName();
  if (userTransactionName == null)   userTransactionName=DEFAULT_USER_TRANSACTION_NAME;
  if (log.isDebugEnabled())   log.debug("String_Node_Str" + userTransactionName + "String_Node_Str");
  synchronizationRegistryName=TransactionManagerServices.getConfiguration().getJndiTransactionSynchronizationRegistryName();
  if (synchronizationRegistryName == null)   synchronizationRegistryName=DEFAULT_SYNCHRONIZATION_REGISTRY_NAME;
  if (log.isDebugEnabled())   log.debug("String_Node_Str" + synchronizationRegistryName + "String_Node_Str");
}
Program: 155481
Project: 155481
Buggy source:
public void afterCompletion(int status){
  if (log.isDebugEnabled())   log.debug("String_Node_Str" + currentTxGtrid);
  statefulHolderTransactionMap.remove(currentTxGtrid);
}

Fixed version (ground truth):
public void afterCompletion(int status){
synchronized (XAPool.this) {
    statefulHolderTransactionMap.remove(currentTxGtrid);
    if (log.isDebugEnabled())     log.debug("String_Node_Str" + currentTxGtrid);
  }
}