nus-yam/ex-repair huggingface dataset:
Program: 41044
Project: 41044
Buggy source:
/** 
 * Creates a BuildPlan for the given ServiceTemplate
 * @param defs an AbstractDefinitions
 * @param csarName the File name of the CSAR the Definitions document isdefined in
 * @param serviceTemplate a QName representing a ServiceTemplate inside thegiven Definitions Document
 * @return a BuildPlan if generating a BuildPlan was successful, else null
 */
protected BuildPlan buildPlan(AbstractDefinitions defs,String csarName,QName serviceTemplate){
  PlanBuilder planBuilder=new PlanBuilder();
  return planBuilder.buildPlan(csarName,defs,serviceTemplate);
}

Fixed version (ground truth):
/** 
 * Creates a BuildPlan for the given ServiceTemplate
 * @param defs an AbstractDefinitions
 * @param csarName the File name of the CSAR the Definitions document isdefined in
 * @param serviceTemplate a QName representing a ServiceTemplate inside thegiven Definitions Document
 * @return a BuildPlan if generating a BuildPlan was successful, else null
 */
public BuildPlan buildPlan(AbstractDefinitions defs,String csarName,QName serviceTemplate){
  PlanBuilder planBuilder=new PlanBuilder();
  return planBuilder.buildPlan(csarName,defs,serviceTemplate);
}
Program: 41045
Project: 41045
Buggy source:
/** 
 * Stores a CSAR given as file object
 * @param file File referencing a CSAR
 * @return an Object representing an ID of the stored CSAR, if somethingwent wrong null is returned instead
 * @throws SystemException
 * @throws UserException
 */
public Object storeCSAR(File file) throws UserException, SystemException {
  CSARHandler.LOG.debug("String_Node_Str");
  BundleContext bundleContext=FrameworkUtil.getBundle(this.getClass()).getBundleContext();
  CSARHandler.LOG.debug("String_Node_Str");
  ServiceReference<?> fileServiceRef=bundleContext.getServiceReference(ICoreFileService.class.getName());
  CSARHandler.LOG.debug("String_Node_Str");
  ICoreFileService fileService=(ICoreFileService)bundleContext.getService(fileServiceRef);
  CSARHandler.LOG.debug("String_Node_Str");
  CSARID csarId=fileService.storeCSAR(file.toPath());
  if (csarId == null) {
    CSARHandler.LOG.warn("String_Node_Str");
    return null;
  }
  CSARHandler.LOG.info("String_Node_Str");
  return csarId;
}

Fixed version (ground truth):
/** 
 * Stores a CSAR given as file object
 * @param file File referencing a CSAR
 * @return an Object representing an ID of the stored CSAR, if somethingwent wrong null is returned instead
 * @throws SystemException
 * @throws UserException
 */
public Object storeCSAR(File file) throws UserException, SystemException {
  CSARHandler.LOG.debug("String_Node_Str");
  ICoreFileService fileService=this.fetchCoreFileService();
  CSARID csarId=fileService.storeCSAR(file.toPath());
  if (csarId == null) {
    CSARHandler.LOG.warn("String_Node_Str");
    return null;
  }
  CSARHandler.LOG.info("String_Node_Str");
  return csarId;
}
Program: 41046
Project: 41046
Buggy source:
/** 
 * Returns a CSARContent Object for the given CSARID
 * @param id a CSARID
 * @return the CSARContent for the given CSARID
 * @throws UserException is thrown when something inside the OpenTOSCA Corefails
 */
public CSARContent getCSARContentForID(CSARID id) throws UserException {
  CSARHandler.LOG.debug("String_Node_Str");
  BundleContext bundleContext=FrameworkUtil.getBundle(this.getClass()).getBundleContext();
  CSARHandler.LOG.debug("String_Node_Str");
  ServiceReference<?> fileServiceRef=bundleContext.getServiceReference(ICoreFileService.class.getName());
  CSARHandler.LOG.debug("String_Node_Str");
  ICoreFileService fileService=(ICoreFileService)bundleContext.getService(fileServiceRef);
  return fileService.getCSAR(id);
}

Fixed version (ground truth):
/** 
 * Returns a CSARContent Object for the given CSARID
 * @param id a CSARID
 * @return the CSARContent for the given CSARID
 * @throws UserException is thrown when something inside the OpenTOSCA Core fails
 */
public CSARContent getCSARContentForID(CSARID id) throws UserException {
  LOG.debug("String_Node_Str");
  return this.fetchCoreFileService().getCSAR(id);
}
Program: 41047
Project: 41047
Buggy source:
/** 
 * Deletes all CSARs in the OpenTOSCA Core
 */
public void deleteAllCsars(){
  CSARHandler.LOG.debug("String_Node_Str");
  BundleContext bundleContext=FrameworkUtil.getBundle(this.getClass()).getBundleContext();
  CSARHandler.LOG.debug("String_Node_Str");
  ServiceReference<?> fileServiceRef=bundleContext.getServiceReference(ICoreFileService.class.getName());
  CSARHandler.LOG.debug("String_Node_Str");
  ICoreFileService fileService=(ICoreFileService)bundleContext.getService(fileServiceRef);
  CSARHandler.LOG.info("String_Node_Str");
  try {
    fileService.deleteCSARs();
  }
 catch (  SystemException e) {
  }
}

Fixed version (ground truth):
/** 
 * Deletes all CSARs in the OpenTOSCA Core
 */
public void deleteAllCsars(){
  CSARHandler.LOG.info("String_Node_Str");
  ICoreFileService fileService=this.fetchCoreFileService();
  try {
    fileService.deleteCSARs();
  }
 catch (  SystemException e) {
  }
}
Program: 41050
Project: 41050
Buggy source:
/** 
 * {@inheritDoc}
 */
@Override public AbstractProperties getProperties(){
  return new PropertiesImpl(this.properties.getAny());
}

Fixed version (ground truth):
/** 
 * {@inheritDoc}
 */
@Override public AbstractProperties getProperties(){
  if (this.properties.getAny() != null) {
    return new PropertiesImpl(this.properties.getAny());
  }
 else {
    return null;
  }
}
Program: 41052
Project: 41052
Buggy source:
/** 
 * Initializes the internal IAs
 */
private void initIas(){
  for (  TImplementationArtifact artifact : this.nodeTypeImpl.getImplementationArtifacts().getImplementationArtifact()) {
    this.ias.add(new ImplementationArtifactImpl(artifact,this.definitions));
  }
}

Fixed version (ground truth):
/** 
 * Initializes the internal IAs
 */
private void initIas(){
  if (this.nodeTypeImpl.getImplementationArtifacts() != null) {
    for (    TImplementationArtifact artifact : this.nodeTypeImpl.getImplementationArtifacts().getImplementationArtifact()) {
      this.ias.add(new ImplementationArtifactImpl(artifact,this.definitions));
    }
  }
}
Program: 41053
Project: 41053
Buggy source:
/** 
 * {@inheritDoc}
 */
@Override public QName getTypeRef(){
  if (this.relationshipType.getDerivedFrom() != null) {
    for (    AbstractRelationshipType relation : this.definitions.getAllRelationshipTypes()) {
      if (relation.getId().toString().equals(this.relationshipType.getDerivedFrom().getTypeRef().toString())) {
        return relation.getTypeRef();
      }
    }
  }
  return null;
}

Fixed version (ground truth):
/** 
 * {@inheritDoc}
 */
@Override public QName getTypeRef(){
  if (this.relationshipType.getDerivedFrom() != null) {
    return this.relationshipType.getDerivedFrom().getTypeRef();
  }
  return null;
}
Program: 41054
Project: 41054
Buggy source:
void getRealmAuctionFileInformation(Realm realm){
  getLogger(this.getClass().getName()).log(Level.INFO,"String_Node_Str" + realm.getRealmDetail());
  Client client=ClientBuilder.newClient();
  Files files=client.target(target + realm.getSlug()).request(MediaType.TEXT_PLAIN).get(Files.class);
  files.getFiles().forEach(auctionFile -> createAuctionFile(realm,auctionFile));
}

Fixed version (ground truth):
void getRealmAuctionFileInformation(Realm realm){
  getLogger(this.getClass().getName()).log(Level.INFO,"String_Node_Str" + realm.getRealmDetail());
  try {
    Client client=ClientBuilder.newClient();
    Files files=client.target(target + realm.getSlug()).request(MediaType.TEXT_PLAIN).get(Files.class);
    files.getFiles().forEach(auctionFile -> createAuctionFile(realm,auctionFile));
  }
 catch (  Exception e) {
    getLogger(this.getClass().getName()).log(Level.INFO,"String_Node_Str" + realm.getRealmDetail());
  }
}
Program: 41055
Project: 41055
Buggy source:
@Override @SuppressWarnings("String_Node_Str") public Object processItem(Object item) throws Exception {
  ResultSet resultSet=(ResultSet)item;
  AuctionItemStatistics auctionItemStatistics=new AuctionItemStatistics();
  auctionItemStatistics.setItemId(resultSet.getInt(1));
  auctionItemStatistics.setQuantity(resultSet.getLong(2));
  auctionItemStatistics.setBid(resultSet.getLong(3));
  auctionItemStatistics.setBuyout(resultSet.getLong(4));
  auctionItemStatistics.setMinBid(resultSet.getLong(5));
  auctionItemStatistics.setMinBuyout(resultSet.getLong(6));
  auctionItemStatistics.setMaxBid(resultSet.getLong(7));
  auctionItemStatistics.setMaxBuyout(resultSet.getLong(8));
  auctionItemStatistics.setTimestamp(getContext().getFileToProcess().getLastModified());
  auctionItemStatistics.setAvgBid((double)(auctionItemStatistics.getBid() / auctionItemStatistics.getQuantity()));
  auctionItemStatistics.setAvgBuyout((double)(auctionItemStatistics.getBuyout() / auctionItemStatistics.getQuantity()));
  auctionItemStatistics.setAuctionHouse(AuctionHouse.valueOf(auctionHouse));
  return auctionItemStatistics;
}

Fixed version (ground truth):
@Override @SuppressWarnings("String_Node_Str") public Object processItem(Object item) throws Exception {
  ResultSet resultSet=(ResultSet)item;
  AuctionItemStatistics auctionItemStatistics=new AuctionItemStatistics();
  auctionItemStatistics.setItemId(resultSet.getInt(1));
  auctionItemStatistics.setQuantity(resultSet.getLong(2));
  auctionItemStatistics.setBid(resultSet.getLong(3));
  auctionItemStatistics.setBuyout(resultSet.getLong(4));
  auctionItemStatistics.setMinBid(resultSet.getLong(5));
  auctionItemStatistics.setMinBuyout(resultSet.getLong(6));
  auctionItemStatistics.setMaxBid(resultSet.getLong(7));
  auctionItemStatistics.setMaxBuyout(resultSet.getLong(8));
  auctionItemStatistics.setTimestamp(getContext().getFileToProcess().getLastModified());
  auctionItemStatistics.setAvgBid((double)(auctionItemStatistics.getBid() / auctionItemStatistics.getQuantity()));
  auctionItemStatistics.setAvgBuyout((double)(auctionItemStatistics.getBuyout() / auctionItemStatistics.getQuantity()));
  auctionItemStatistics.setAuctionHouse(AuctionHouse.valueOf(auctionHouse));
  auctionItemStatistics.setRealm(getContext().getRealm());
  return auctionItemStatistics;
}
Program: 41056
Project: 41056
Buggy source:
@Override public void open(Serializable checkpoint) throws Exception {
  Connection connection=dataSource.getConnection();
  preparedStatement=connection.prepareStatement("String_Node_Str" + "String_Node_Str" + "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str",ResultSet.TYPE_FORWARD_ONLY,ResultSet.CONCUR_READ_ONLY,ResultSet.HOLD_CURSORS_OVER_COMMIT);
  preparedStatement.setLong(1,getContext().getFileToProcess().getId());
  preparedStatement.setInt(2,AuctionHouse.valueOf(auctionHouse).ordinal());
  resultSet=preparedStatement.executeQuery();
}

Fixed version (ground truth):
@Override public void open(Serializable checkpoint) throws Exception {
  Connection connection=dataSource.getConnection();
  preparedStatement=connection.prepareStatement("String_Node_Str" + "String_Node_Str" + "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str" + getContext().getFileToProcess().getId() + "String_Node_Str"+ AuctionHouse.valueOf(auctionHouse).ordinal()+ "String_Node_Str"+ "String_Node_Str",ResultSet.TYPE_FORWARD_ONLY,ResultSet.CONCUR_READ_ONLY,ResultSet.HOLD_CURSORS_OVER_COMMIT);
  resultSet=preparedStatement.executeQuery();
}
Program: 41057
Project: 41057
Buggy source:
@Override @GET @Path("String_Node_Str") public List<AuctionItemStatistics> findAuctionItemStatisticsByRealmAndItem(@QueryParam("String_Node_Str") Long realmId,@QueryParam("String_Node_Str") Integer itemId){
  return em.createNamedQuery("String_Node_Str").setParameter("String_Node_Str",itemId).getResultList();
}

Fixed version (ground truth):
@Override @GET @Path("String_Node_Str") public List<AuctionItemStatistics> findAuctionItemStatisticsByRealmAndItem(@QueryParam("String_Node_Str") Long realmId,@QueryParam("String_Node_Str") Integer itemId){
  return em.createNamedQuery("String_Node_Str").setParameter("String_Node_Str",realmId).setParameter("String_Node_Str",itemId).getResultList();
}
Program: 41058
Project: 41058
Buggy source:
private void getRealmAuctionFileInformation(Realm realm){
  getLogger(this.getClass().getName()).log(Level.INFO,"String_Node_Str" + realm.getRealmDetail());
  Client client=ClientBuilder.newClient();
  Files files=client.target(target + realm.getSlug()).request(MediaType.TEXT_PLAIN).get(Files.class);
  files.getFiles().forEach(auctionFile -> {
    auctionFile.setRealm(realm);
    auctionFile.setFileStatus(FileStatus.LOADED);
    woWBusiness.createAuctionFile(auctionFile);
  }
);
}

Fixed version (ground truth):
private void getRealmAuctionFileInformation(Realm realm){
  getLogger(this.getClass().getName()).log(Level.INFO,"String_Node_Str" + realm.getRealmDetail());
  Client client=ClientBuilder.newClient();
  Files files=client.target(target + realm.getSlug()).request(MediaType.TEXT_PLAIN).get(Files.class);
  files.getFiles().forEach(auctionFile -> {
    auctionFile.setRealm(realm);
    auctionFile.setFileName("String_Node_Str" + auctionFile.getLastModified() + "String_Node_Str");
    auctionFile.setFileStatus(FileStatus.LOADED);
    woWBusiness.createAuctionFile(auctionFile);
  }
);
}
Program: 41059
Project: 41059
Buggy source:
private void verifyAndCreateFolder(String folderRoot,Realm realm,FolderType folderType){
  File folder=new File(batchHome + "String_Node_Str" + folderRoot+ "String_Node_Str"+ realm.getName()+ "String_Node_Str"+ folderType);
  if (!folder.exists()) {
    try {
      getLogger(this.getClass().getName()).log(Level.INFO,"String_Node_Str" + folder);
      FileUtils.forceMkdir(folder);
      woWBusiness.createRealmFolder(new RealmFolder(realm.getId(),folderType,folder.getPath()));
    }
 catch (    IOException e) {
      e.printStackTrace();
    }
  }
 else   if (woWBusiness.findRealmFolderById(realm.getId(),folderType) == null) {
    woWBusiness.createRealmFolder(new RealmFolder(realm.getId(),folderType,folder.getPath()));
  }
}

Fixed version (ground truth):
private void verifyAndCreateFolder(String folderRoot,Realm realm,FolderType folderType){
  File folder=new File(batchHome + "String_Node_Str" + folderRoot+ "String_Node_Str"+ realm.getRegion()+ "String_Node_Str"+ realm.getName()+ "String_Node_Str"+ folderType);
  if (!folder.exists()) {
    try {
      getLogger(this.getClass().getName()).log(Level.INFO,"String_Node_Str" + folder);
      FileUtils.forceMkdir(folder);
      woWBusiness.createRealmFolder(new RealmFolder(realm.getId(),folderType,folder.getPath()));
    }
 catch (    IOException e) {
      e.printStackTrace();
    }
  }
 else   if (woWBusiness.findRealmFolderById(realm.getId(),folderType) == null) {
    woWBusiness.createRealmFolder(new RealmFolder(realm.getId(),folderType,folder.getPath()));
  }
}
Program: 41062
Project: 41062
Buggy source:
@Override public int getPriority(){
  return PRIORITY.LOWEST.getValue();
}

Fixed version (ground truth):
@Override public int getPriority(){
  return PRIORITY.LOWER_STILL.getValue();
}
Program: 41063
Project: 41063
Buggy source:
/** 
 * Process the SASL authentication cycle until such time as an outcome is determine. This method must be called by the managing entity until the return value is true indicating a successful authentication or a JMSSecurityException is thrown indicating that the handshake failed.
 * @param authenticationRequest The request that is awaiting the result of authentication.
 * @return true if the authentication process completed.
 */
public boolean authenticate() throws JMSSecurityException {
  try {
switch (sasl.getState()) {
case PN_SASL_IDLE:
      handleSaslInit();
    break;
case PN_SASL_STEP:
  handleSaslStep();
break;
case PN_SASL_FAIL:
handleSaslFail();
break;
case PN_SASL_PASS:
authenticationRequest.onSuccess();
default :
break;
}
}
 catch (JMSSecurityException result) {
authenticationRequest.onFailure(result);
}
return authenticationRequest.isComplete();
}

Fixed version (ground truth):
/** 
 * Process the SASL authentication cycle until such time as an outcome is determine. This method must be called by the managing entity until the return value is true indicating a successful authentication or a JMSSecurityException is thrown indicating that the handshake failed.
 * @return true if the authentication process completed.
 */
public boolean authenticate() throws JMSSecurityException {
  try {
switch (sasl.getState()) {
case PN_SASL_IDLE:
      handleSaslInit();
    break;
case PN_SASL_STEP:
  handleSaslStep();
break;
case PN_SASL_FAIL:
handleSaslFail();
break;
case PN_SASL_PASS:
authenticationRequest.onSuccess();
default :
break;
}
}
 catch (JMSSecurityException result) {
authenticationRequest.onFailure(result);
}
return authenticationRequest.isComplete();
}
Program: 41064
Project: 41064
Buggy source:
/** 
 * When a redirect type exception is received this method is called to create the appropriate redirect exception type containing the error details needed.
 * @param error the Symbol that defines the redirection error type.
 * @param message the basic error message that should used or amended for the returned exception.
 * @param condition the ErrorCondition that describes the redirection.
 * @return an Exception that captures the details of the redirection error.
 */
public static Exception createRedirectException(Symbol error,String message,ErrorCondition condition){
  Exception result=null;
  Map<?,?> info=condition.getInfo();
  if (info == null) {
    result=new IOException(message + "String_Node_Str");
  }
 else {
    String hostname=(String)info.get(OPEN_HOSTNAME);
    String networkHost=(String)info.get(NETWORK_HOST);
    if (networkHost == null || networkHost.isEmpty()) {
      result=new IOException(message + "String_Node_Str");
    }
    int port=0;
    try {
      port=Integer.valueOf(info.get(PORT).toString());
    }
 catch (    Exception ex) {
      result=new IOException(message + "String_Node_Str");
    }
    result=new ProviderRedirectedException(message,hostname,networkHost,port);
  }
  return result;
}

Fixed version (ground truth):
/** 
 * When a redirect type exception is received this method is called to create the appropriate redirect exception type containing the error details needed.
 * @param error the Symbol that defines the redirection error type.
 * @param message the basic error message that should used or amended for the returned exception.
 * @param condition the ErrorCondition that describes the redirection.
 * @return an Exception that captures the details of the redirection error.
 */
public static Exception createRedirectException(Symbol error,String message,ErrorCondition condition){
  Exception result=null;
  Map<?,?> info=condition.getInfo();
  if (info == null) {
    result=new IOException(message + "String_Node_Str");
  }
 else {
    String hostname=(String)info.get(OPEN_HOSTNAME);
    String networkHost=(String)info.get(NETWORK_HOST);
    if (networkHost == null || networkHost.isEmpty()) {
      result=new IOException(message + "String_Node_Str");
    }
    int port=0;
    try {
      port=Integer.parseInt(info.get(PORT).toString());
    }
 catch (    Exception ex) {
      result=new IOException(message + "String_Node_Str");
    }
    result=new ProviderRedirectedException(message,hostname,networkHost,port);
  }
  return result;
}
Program: 41065
Project: 41065
Buggy source:
@Override public void processDeliveryUpdates(AmqpProvider provider) throws IOException {
  try {
    if (pendingDelivery != null && pendingDelivery.remotelySettled()) {
      DeliveryState state=pendingDelivery.getRemoteState();
      JmsTransactionId txId=(JmsTransactionId)pendingDelivery.getContext();
      if (state instanceof Declared) {
        LOG.debug("String_Node_Str",txId);
        Declared declared=(Declared)state;
        txId.setProviderHint(declared.getTxnId());
        pendingRequest.onSuccess();
      }
 else       if (state instanceof Rejected) {
        LOG.debug("String_Node_Str",txId);
        Rejected rejected=(Rejected)state;
        Exception cause=AmqpSupport.convertToException(getEndpoint(),rejected.getError());
        JMSException failureCause=null;
        if (txId.getProviderContext() == COMMIT_MARKER) {
          failureCause=new TransactionRolledBackException(cause.getMessage());
        }
 else {
          failureCause=new JMSException(cause.getMessage());
        }
        pendingRequest.onFailure(failureCause);
      }
 else {
        LOG.debug("String_Node_Str",txId);
        pendingRequest.onSuccess();
      }
      pendingDelivery.settle();
      pendingRequest=null;
      pendingDelivery=null;
      if (pendingTimeout != null) {
        pendingTimeout.cancel(false);
        pendingTimeout=null;
      }
    }
    super.processDeliveryUpdates(provider);
  }
 catch (  Exception e) {
    throw IOExceptionSupport.create(e);
  }
}

Fixed version (ground truth):
@Override public void processDeliveryUpdates(AmqpProvider provider) throws IOException {
  try {
    if (pendingDelivery != null && pendingDelivery.remotelySettled()) {
      DeliveryState state=pendingDelivery.getRemoteState();
      JmsTransactionId txId=(JmsTransactionId)pendingDelivery.getContext();
      if (state instanceof Declared) {
        LOG.debug("String_Node_Str",txId);
        Declared declared=(Declared)state;
        txId.setProviderHint(declared.getTxnId());
        pendingRequest.onSuccess();
      }
 else       if (state instanceof Rejected) {
        LOG.debug("String_Node_Str",txId);
        Rejected rejected=(Rejected)state;
        Exception cause=AmqpSupport.convertToException(getEndpoint(),rejected.getError());
        JMSException failureCause=null;
        if (txId.getProviderContext().equals(COMMIT_MARKER)) {
          failureCause=new TransactionRolledBackException(cause.getMessage());
        }
 else {
          failureCause=new JMSException(cause.getMessage());
        }
        pendingRequest.onFailure(failureCause);
      }
 else {
        LOG.debug("String_Node_Str",txId);
        pendingRequest.onSuccess();
      }
      pendingDelivery.settle();
      pendingRequest=null;
      pendingDelivery=null;
      if (pendingTimeout != null) {
        pendingTimeout.cancel(false);
        pendingTimeout=null;
      }
    }
    super.processDeliveryUpdates(provider);
  }
 catch (  Exception e) {
    throw IOExceptionSupport.create(e);
  }
}
Program: 41066
Project: 41066
Buggy source:
@Test(timeout=30000) public void testQueueBrowserNextElementWithNoMessage() throws IOException, Exception {
  try (TestAmqpPeer testPeer=new TestAmqpPeer()){
    Connection connection=testFixture.establishConnecton(testPeer);
    connection.start();
    testPeer.expectBegin();
    Session session=connection.createSession(false,Session.AUTO_ACKNOWLEDGE);
    Queue queue=session.createQueue("String_Node_Str");
    testPeer.expectQueueBrowserAttach();
    testPeer.expectLinkFlow();
    testPeer.expectLinkFlow(true,true,equalTo(UnsignedInteger.valueOf(1)));
    testPeer.expectDetach(true,true,true);
    QueueBrowser browser=session.createBrowser(queue);
    Enumeration<?> queueView=browser.getEnumeration();
    assertNotNull(queueView);
    assertNull(queueView.nextElement());
    browser.close();
    testPeer.waitForAllHandlersToComplete(3000);
  }
 }

Fixed version (ground truth):
@Test(timeout=30000) public void testQueueBrowserNextElementWithNoMessage() throws IOException, Exception {
  try (TestAmqpPeer testPeer=new TestAmqpPeer()){
    Connection connection=testFixture.establishConnecton(testPeer);
    connection.start();
    testPeer.expectBegin();
    Session session=connection.createSession(false,Session.AUTO_ACKNOWLEDGE);
    Queue queue=session.createQueue("String_Node_Str");
    testPeer.expectQueueBrowserAttach();
    testPeer.expectLinkFlow();
    testPeer.expectLinkFlow(true,true,equalTo(UnsignedInteger.valueOf(JmsPrefetchPolicy.DEFAULT_QUEUE_BROWSER_PREFETCH)));
    testPeer.expectDetach(true,true,true);
    QueueBrowser browser=session.createBrowser(queue);
    Enumeration<?> queueView=browser.getEnumeration();
    assertNotNull(queueView);
    assertNull(queueView.nextElement());
    browser.close();
    testPeer.waitForAllHandlersToComplete(3000);
  }
 }
Program: 41071
Project: 41071
Buggy source:
/** 
 * @throws JMSException
 * @see javax.jms.MessageConsumer#close()
 */
@Override public void close() throws JMSException {
  if (!closed.get()) {
    session.getTransactionContext().addSynchronization(new JmsTxSynchronization(){
      @Override public boolean validate(      JmsTransactionContext context) throws Exception {
        if (!context.isInTransaction() || !delivered.get()) {
          doClose();
          return false;
        }
        return true;
      }
      @Override public void afterCommit() throws Exception {
        doClose();
      }
      @Override public void afterRollback() throws Exception {
        doClose();
      }
    }
);
  }
}

Fixed version (ground truth):
/** 
 * @throws JMSException
 * @see javax.jms.MessageConsumer#close()
 */
@Override public void close() throws JMSException {
  if (!closed.get()) {
    session.getTransactionContext().addSynchronization(new JmsTxSynchronization(){
      @Override public boolean validate(      JmsTransactionContext context) throws Exception {
        if (!context.isInTransaction() || !delivered.get() || isBrowser()) {
          doClose();
          return false;
        }
        return true;
      }
      @Override public void afterCommit() throws Exception {
        doClose();
      }
      @Override public void afterRollback() throws Exception {
        doClose();
      }
    }
);
  }
}
Program: 41072
Project: 41072
Buggy source:
@Override public boolean validate(JmsTransactionContext context) throws Exception {
  if (!context.isInTransaction() || !delivered.get()) {
    doClose();
    return false;
  }
  return true;
}

Fixed version (ground truth):
@Override public boolean validate(JmsTransactionContext context) throws Exception {
  if (!context.isInTransaction() || !delivered.get() || isBrowser()) {
    doClose();
    return false;
  }
  return true;
}
Program: 41073
Project: 41073
Buggy source:
/** 
 * Remove a URI from the pool if present, otherwise has no effect.
 * @param uri The URI to attempt to remove from the pool.
 * @returns true if the given URI was removed from the pool.
 */
public boolean remove(URI uri){
  if (uri == null) {
    return false;
  }
synchronized (uris) {
    for (    URI candidate : uris) {
      if (compareURIs(uri,candidate)) {
        return uris.remove(candidate);
      }
    }
  }
  return false;
}

Fixed version (ground truth):
/** 
 * Remove a URI from the pool if present, otherwise has no effect.
 * @param uri The URI to attempt to remove from the pool.
 * @return true if the given URI was removed from the pool.
 */
public boolean remove(URI uri){
  if (uri == null) {
    return false;
  }
synchronized (uris) {
    for (    URI candidate : uris) {
      if (compareURIs(uri,candidate)) {
        return uris.remove(candidate);
      }
    }
  }
  return false;
}
Program: 41074
Project: 41074
Buggy source:
/** 
 * When a redirect type exception is received this method is called to create the appropriate redirect exception type containing the error details needed.
 * @param error the Symbol that defines the redirection error type.
 * @param message the basic error message that should used or amended for the returned exception.
 * @param condition the ErrorCondition that describes the redirection.
 * @returns an Exception that captures the details of the redirection error.
 */
@SuppressWarnings("String_Node_Str") protected Exception createRedirectException(Symbol error,String message,ErrorCondition condition){
  Exception result=null;
  Map<String,Object> info=condition.getInfo();
  if (info == null) {
    result=new IOException(message + "String_Node_Str");
  }
 else {
    String hostname=(String)info.get("String_Node_Str");
    String networkHost=(String)info.get("String_Node_Str");
    if (networkHost == null || networkHost.isEmpty()) {
      result=new IOException(message + "String_Node_Str");
    }
    int port=0;
    try {
      port=Integer.valueOf(info.get("String_Node_Str").toString());
    }
 catch (    Exception ex) {
      result=new IOException(message + "String_Node_Str");
    }
    result=new ProviderRedirectedException(message,hostname,networkHost,port);
  }
  return result;
}

Fixed version (ground truth):
/** 
 * When a redirect type exception is received this method is called to create the appropriate redirect exception type containing the error details needed.
 * @param error the Symbol that defines the redirection error type.
 * @param message the basic error message that should used or amended for the returned exception.
 * @param condition the ErrorCondition that describes the redirection.
 * @return an Exception that captures the details of the redirection error.
 */
@SuppressWarnings("String_Node_Str") protected Exception createRedirectException(Symbol error,String message,ErrorCondition condition){
  Exception result=null;
  Map<String,Object> info=condition.getInfo();
  if (info == null) {
    result=new IOException(message + "String_Node_Str");
  }
 else {
    String hostname=(String)info.get("String_Node_Str");
    String networkHost=(String)info.get("String_Node_Str");
    if (networkHost == null || networkHost.isEmpty()) {
      result=new IOException(message + "String_Node_Str");
    }
    int port=0;
    try {
      port=Integer.valueOf(info.get("String_Node_Str").toString());
    }
 catch (    Exception ex) {
      result=new IOException(message + "String_Node_Str");
    }
    result=new ProviderRedirectedException(message,hostname,networkHost,port);
  }
  return result;
}
Program: 41075
Project: 41075
Buggy source:
/** 
 * Indicates if this DiscoveryAgent requires a ScheduledExecutorService in order to perform its discovery work.
 * @returns true if the agent requires that its parent provide it with a scheduler.
 */
boolean isSchedulerRequired();

Fixed version (ground truth):
/** 
 * Indicates if this DiscoveryAgent requires a ScheduledExecutorService in order to perform its discovery work.
 * @return true if the agent requires that its parent provide it with a scheduler.
 */
boolean isSchedulerRequired();
Program: 41076
Project: 41076
Buggy source:
@Test(timeout=5000) public void testCreateTemporaryTopicFailsWhenLinkRefusedAndAttachResponseWriteIsDeferred() throws Exception {
  doCreateTemporaryDestinationFailsWhenLinkRefusedTestImpl(false,true);
}

Fixed version (ground truth):
@Test(timeout=5000) public void testCreateTemporaryTopicFailsWhenLinkRefusedAndAttachResponseWriteIsDeferred() throws Exception {
  doCreateTemporaryDestinationFailsWhenLinkRefusedTestImpl(true,true);
}
Program: 41077
Project: 41077
Buggy source:
private void doCreateTemporaryDestinationFailsWhenLinkRefusedTestImpl(boolean topic,boolean deferAttachResponseWrite) throws Exception {
  try (TestAmqpPeer testPeer=new TestAmqpPeer()){
    Connection connection=testFixture.establishConnecton(testPeer);
    connection.start();
    testPeer.expectBegin(true);
    Session session=connection.createSession(false,Session.AUTO_ACKNOWLEDGE);
    testPeer.expectAndRefuseTempQueueCreationAttach(AmqpError.UNAUTHORIZED_ACCESS,"String_Node_Str",false);
    try {
      if (topic) {
        session.createTemporaryTopic();
      }
 else {
        session.createTemporaryQueue();
      }
      fail("String_Node_Str");
    }
 catch (    JMSSecurityException jmsse) {
    }
    testPeer.waitForAllHandlersToComplete(1000);
  }
 }

Fixed version (ground truth):
private void doCreateTemporaryDestinationFailsWhenLinkRefusedTestImpl(boolean topic,boolean deferAttachResponseWrite) throws Exception {
  try (TestAmqpPeer testPeer=new TestAmqpPeer()){
    Connection connection=testFixture.establishConnecton(testPeer);
    connection.start();
    testPeer.expectBegin(true);
    Session session=connection.createSession(false,Session.AUTO_ACKNOWLEDGE);
    try {
      if (topic) {
        testPeer.expectAndRefuseTempTopicCreationAttach(AmqpError.UNAUTHORIZED_ACCESS,"String_Node_Str",false);
        session.createTemporaryTopic();
      }
 else {
        testPeer.expectAndRefuseTempQueueCreationAttach(AmqpError.UNAUTHORIZED_ACCESS,"String_Node_Str",false);
        session.createTemporaryQueue();
      }
      fail("String_Node_Str");
    }
 catch (    JMSSecurityException jmsse) {
    }
    testPeer.waitForAllHandlersToComplete(1000);
  }
 }
Program: 41078
Project: 41078
Buggy source:
@Test(timeout=5000) public void testCreateTemporaryTopicFailsWhenLinkRefusedAndAttachResponseWriteIsNotDeferred() throws Exception {
  doCreateTemporaryDestinationFailsWhenLinkRefusedTestImpl(false,false);
}

Fixed version (ground truth):
@Test(timeout=5000) public void testCreateTemporaryTopicFailsWhenLinkRefusedAndAttachResponseWriteIsNotDeferred() throws Exception {
  doCreateTemporaryDestinationFailsWhenLinkRefusedTestImpl(true,false);
}
Program: 41079
Project: 41079
Buggy source:
private static TrustManager[] loadTrustManagers(TransportSslOptions options) throws Exception {
  if (options.getTrustStoreLocation() == null) {
    return null;
  }
  TrustManagerFactory fact=TrustManagerFactory.getInstance(TrustManagerFactory.getDefaultAlgorithm());
  String storeLocation=options.getKeyStoreLocation();
  String storePassword=options.getKeyStorePassword();
  String storeType=options.getStoreType();
  LOG.trace("String_Node_Str",storeLocation,storeType);
  KeyStore trustStore=loadStore(storeLocation,storePassword,storeType);
  fact.init(trustStore);
  return fact.getTrustManagers();
}

Fixed version (ground truth):
private static TrustManager[] loadTrustManagers(TransportSslOptions options) throws Exception {
  if (options.getTrustStoreLocation() == null) {
    return null;
  }
  TrustManagerFactory fact=TrustManagerFactory.getInstance(TrustManagerFactory.getDefaultAlgorithm());
  String storeLocation=options.getTrustStoreLocation();
  String storePassword=options.getTrustStorePassword();
  String storeType=options.getStoreType();
  LOG.trace("String_Node_Str",storeLocation,storeType);
  KeyStore trustStore=loadStore(storeLocation,storePassword,storeType);
  fact.init(trustStore);
  return fact.getTrustManagers();
}
Program: 41081
Project: 41081
Buggy source:
/** 
 * Triggers a pull request from the connected Provider.  An attempt is made to set a timeout on the pull request however some providers will not honor this value and the pull will remain active until a message is dispatched. The timeout value can be one of: < 0 to indicate that the request should expire immediately if no message. = 0 to indicate that the request should never time out. > 1 to indicate that the request should expire after the given time in milliseconds.
 * @param timeout The amount of time the pull request should remain valid.
 */
protected void sendPullCommand(long timeout) throws JMSException {
  if (messageQueue.isEmpty() && (getPrefetchSize() == 0 || isBrowser())) {
    connection.pull(getConsumerId(),timeout);
  }
}

Fixed version (ground truth):
/** 
 * Triggers a pull request from the connected Provider.  An attempt is made to set a timeout on the pull request however some providers will not honor this value and the pull will remain active until a message is dispatched. <p> The timeout value can be one of: <br>  {@literal < 0} to indicate that the request should expire immediately if no message.<br>{@literal = 0} to indicate that the request should never time out.<br>{@literal > 1} to indicate that the request should expire after the given time in milliseconds.
 * @param timeout The amount of time the pull request should remain valid.
 */
protected void sendPullCommand(long timeout) throws JMSException {
  if (messageQueue.isEmpty() && (getPrefetchSize() == 0 || isBrowser())) {
    connection.pull(getConsumerId(),timeout);
  }
}
Program: 41082
Project: 41082
Buggy source:
/** 
 * Called to indicate that the underlying connection to the Broker has been established for the first time.  For a fault tolerant provider this event should only ever be triggered once with the interruption and recovery events following on for future
 * @param ex The exception that indicates the cause of this Provider failure.
 */
void onConnectionEstablished(URI remoteURI);

Fixed version (ground truth):
/** 
 * Called to indicate that the underlying connection to the Broker has been established for the first time.  For a fault tolerant provider this event should only ever be triggered once with the interruption and recovery events following on for future
 * @param remoteURI The URI of the Broker that the client has now connected to.
 */
void onConnectionEstablished(URI remoteURI);
Program: 41083
Project: 41083
Buggy source:
/** 
 * Sets any additional Mechanism specific properties using a Map<String, Object>
 * @param options the map of additional properties that this Mechanism should utilize.
 */
void setProperties(Map<String,Object> options);

Fixed version (ground truth):
/** 
 * Sets any additional Mechanism specific properties using a   {@code Map<String, Object>}
 * @param options the map of additional properties that this Mechanism should utilize.
 */
void setProperties(Map<String,Object> options);
Program: 41084
Project: 41084
Buggy source:
/** 
 * Validates that the expression can be used in == or <> expression. Cannot not be NULL TRUE or FALSE litterals.
 * @param expr
 */
public static void checkEqualOperand(Expression expr){
  if (expr instanceof ConstantExpression) {
    Object value=((ConstantExpression)expr).getValue();
    if (value == null) {
      throw new RuntimeException("String_Node_Str" + expr + "String_Node_Str");
    }
  }
}

Fixed version (ground truth):
/** 
 * Validates that the expression can be used in   {@literal == or <>} expressions. Cannotnot be NULL TRUE or FALSE literals.
 * @param expr
 */
public static void checkEqualOperand(Expression expr){
  if (expr instanceof ConstantExpression) {
    Object value=((ConstantExpression)expr).getValue();
    if (value == null) {
      throw new RuntimeException("String_Node_Str" + expr + "String_Node_Str");
    }
  }
}
Program: 41085
Project: 41085
Buggy source:
/** 
 * Only Numeric expressions can be used in >, >=, < or <= expressions.s
 * @param expr
 */
public static void checkLessThanOperand(Expression expr){
  if (expr instanceof ConstantExpression) {
    Object value=((ConstantExpression)expr).getValue();
    if (value instanceof Number) {
      return;
    }
    throw new RuntimeException("String_Node_Str" + expr + "String_Node_Str");
  }
  if (expr instanceof BooleanExpression) {
    throw new RuntimeException("String_Node_Str" + expr + "String_Node_Str");
  }
}

Fixed version (ground truth):
/** 
 * Only Numeric expressions can be used in   {@literal >, >=, < or <=} expressions.
 * @param expr
 */
public static void checkLessThanOperand(Expression expr){
  if (expr instanceof ConstantExpression) {
    Object value=((ConstantExpression)expr).getValue();
    if (value instanceof Number) {
      return;
    }
    throw new RuntimeException("String_Node_Str" + expr + "String_Node_Str");
  }
  if (expr instanceof BooleanExpression) {
    throw new RuntimeException("String_Node_Str" + expr + "String_Node_Str");
  }
}
Program: 41086
Project: 41086
Buggy source:
/** 
 * Constructor for an JmsQueueBrowser - used internally
 * @param session
 * @param id
 * @param destination
 * @param selector
 * @throws javax.jms.JMSException
 */
protected JmsQueueBrowser(JmsSession session,JmsDestination destination,String selector) throws JMSException {
  this.session=session;
  this.destination=destination;
  this.selector=selector;
}

Fixed version (ground truth):
/** 
 * Constructor for an JmsQueueBrowser - used internally
 * @param session
 * @param destination
 * @param selector
 * @throws javax.jms.JMSException
 */
protected JmsQueueBrowser(JmsSession session,JmsDestination destination,String selector) throws JMSException {
  this.session=session;
  this.destination=destination;
  this.selector=selector;
}
Program: 41087
Project: 41087
Buggy source:
/** 
 * Sets a value which will be used to override any ttl value that may otherwise be set based on the expiration value when sending the underlying AMQP message. A value of 0 means to clear the ttl field rather than set it to anything.
 * @param ttl the value to use, in range 0 <= x <= 2^32 - 1
 * @throws MessageFormatException
 */
public void setAmqpTimeToLiveOverride(Long ttl) throws MessageFormatException {
  if (ttl != null) {
    if (ttl >= 0 && ttl <= UINT_MAX) {
      userSpecifiedTTL=ttl;
    }
 else {
      throw new MessageFormatException(JMS_AMQP_TTL + "String_Node_Str");
    }
  }
 else {
    userSpecifiedTTL=null;
  }
}

Fixed version (ground truth):
/** 
 * Sets a value which will be used to override any ttl value that may otherwise be set based on the expiration value when sending the underlying AMQP message. A value of 0 means to clear the ttl field rather than set it to anything.
 * @param ttl the value to use, in range  {@literal 0 <= x <= 2^32 - 1}
 * @throws MessageFormatException
 */
public void setAmqpTimeToLiveOverride(Long ttl) throws MessageFormatException {
  if (ttl != null) {
    if (ttl >= 0 && ttl <= UINT_MAX) {
      userSpecifiedTTL=ttl;
    }
 else {
      throw new MessageFormatException(JMS_AMQP_TTL + "String_Node_Str");
    }
  }
 else {
    userSpecifiedTTL=null;
  }
}
Program: 41088
Project: 41088
Buggy source:
/** 
 * Gets the current setting controlling how many Connect / Reconnect attempts must occur before a warn message is logged.  A value of   {@code <= 0} indicates that there will beno warn message logged regardless of how many reconnect attempts occur.
 * @return the current number of connection attempts before warn logging is triggered.
 */
public int getWarnAfterReconnectAttempts(){
  return warnAfterReconnectAttempts;
}

Fixed version (ground truth):
/** 
 * Gets the current setting controlling how many Connect / Reconnect attempts must occur before a warn message is logged.  A value of   {@literal <= 0} indicates that there will beno warn message logged regardless of how many reconnect attempts occur.
 * @return the current number of connection attempts before warn logging is triggered.
 */
public int getWarnAfterReconnectAttempts(){
  return warnAfterReconnectAttempts;
}
Program: 41089
Project: 41089
Buggy source:
/** 
 * Sets the number of Connect / Reconnect attempts that must occur before a warn message is logged indicating that the transport is not connected.  This can be useful when the client is running inside some container or service as it gives an indication of some problem with the client connection that might not otherwise be visible.  To disable the log messages this value should be set to a value @{code attempts <= 0}
 * @param warnAfterReconnectAttempts The number of failed connection attempts that must happen before a warning is logged.
 */
public void setWarnAfterReconnectAttempts(int warnAfterReconnectAttempts){
  this.warnAfterReconnectAttempts=warnAfterReconnectAttempts;
}

Fixed version (ground truth):
/** 
 * Sets the number of Connect / Reconnect attempts that must occur before a warn message is logged indicating that the transport is not connected.  This can be useful when the client is running inside some container or service as it gives an indication of some problem with the client connection that might not otherwise be visible.  To disable the log messages this value should be set to a value   {@literal <= 0}
 * @param warnAfterReconnectAttempts The number of failed connection attempts that must happen before a warning is logged.
 */
public void setWarnAfterReconnectAttempts(int warnAfterReconnectAttempts){
  this.warnAfterReconnectAttempts=warnAfterReconnectAttempts;
}
Program: 41090
Project: 41090
Buggy source:
/** 
 * Does a proper compare on the Id's
 * @param id1
 * @param id2
 * @return 0 if equal else a positive if id1 is > id2 ...
 */
public static int compare(String id1,String id2){
  int result=-1;
  String seed1=IdGenerator.getSeedFromId(id1);
  String seed2=IdGenerator.getSeedFromId(id2);
  if (seed1 != null && seed2 != null) {
    result=seed1.compareTo(seed2);
    if (result == 0) {
      long count1=IdGenerator.getSequenceFromId(id1);
      long count2=IdGenerator.getSequenceFromId(id2);
      result=(int)(count1 - count2);
    }
  }
  return result;
}

Fixed version (ground truth):
/** 
 * Does a proper compare on the Id's
 * @param id1
 * @param id2
 * @return 0 if equal else a positive if {@literal id1 > id2} ...
 */
public static int compare(String id1,String id2){
  int result=-1;
  String seed1=IdGenerator.getSeedFromId(id1);
  String seed2=IdGenerator.getSeedFromId(id2);
  if (seed1 != null && seed2 != null) {
    result=seed1.compareTo(seed2);
    if (result == 0) {
      long count1=IdGenerator.getSequenceFromId(id1);
      long count2=IdGenerator.getSequenceFromId(id2);
      result=(int)(count1 - count2);
    }
  }
  return result;
}
Program: 41091
Project: 41091
Buggy source:
/** 
 * Used to get an enqueued message. The amount of time this method blocks is based on the timeout value. - if timeout==-1 then it blocks until a message is received. - if timeout==0 then it it tries to not block at all, it returns a message if it is available - if timeout>0 then it blocks up to timeout amount of time. Expired messages will consumed by this method.
 * @return null if we timeout or if the consumer is closed.
 * @throws InterruptedException if the wait is interrupted.
 */
JmsInboundMessageDispatch dequeue(long timeout) throws InterruptedException ;

Fixed version (ground truth):
/** 
 * Used to get an enqueued message. The amount of time this method blocks is based on the timeout value. - if timeout==-1 then it blocks until a message is received. - if timeout==0 then it it tries to not block at all, it returns a message if it is available - if   {@literal timeout > 0} then itblocks up to timeout amount of time. Expired messages will consumed by this method.
 * @return null if we timeout or if the consumer is closed.
 * @throws InterruptedException if the wait is interrupted.
 */
JmsInboundMessageDispatch dequeue(long timeout) throws InterruptedException ;
Program: 41092
Project: 41092
Buggy source:
/** 
 * Parse properties from a named resource -eg. a URI or a simple name e.g. foo?name="fred"&size=2
 * @param uri the URI whose parameters are to be parsed.
 * @return <Code>Map</Code> of properties
 * @throws Exception if an error occurs while parsing the query options.
 */
public static Map<String,String> parseParameters(String uri) throws Exception {
  if (uri == null) {
    return Collections.emptyMap();
  }
  return parseQuery(stripUpto(uri,'?'));
}

Fixed version (ground truth):
/** 
 * Parse properties from a named resource -eg. a URI or a simple name e.g.  {@literal foo?name="fred"&size=2}
 * @param uri the URI whose parameters are to be parsed.
 * @return <Code>Map</Code> of properties
 * @throws Exception if an error occurs while parsing the query options.
 */
public static Map<String,String> parseParameters(String uri) throws Exception {
  if (uri == null) {
    return Collections.emptyMap();
  }
  return parseQuery(stripUpto(uri,'?'));
}
Program: 41093
Project: 41093
Buggy source:
/** 
 * @param topic
 * @param name
 * @param messageSelector
 * @param noLocal
 * @return the durable TopicSubscriber
 * @throws IllegalStateException
 * @throws JMSException
 * @see javax.jms.Session#createDurableSubscriber(javax.jms.Topic,java.lang.String,java.lang.String,boolean)
 */
@Override public TopicSubscriber createDurableSubscriber(Topic topic,String name,String messageSelector,boolean noLocal) throws IllegalStateException {
  throw new IllegalStateException("String_Node_Str");
}

Fixed version (ground truth):
/** 
 * @param topic
 * @param name
 * @param messageSelector
 * @param noLocal
 * @return the durable TopicSubscriber
 * @throws JMSException
 * @see javax.jms.Session#createDurableSubscriber(javax.jms.Topic,java.lang.String,java.lang.String,boolean)
 */
@Override public TopicSubscriber createDurableSubscriber(Topic topic,String name,String messageSelector,boolean noLocal) throws JMSException {
  throw new IllegalStateException("String_Node_Str");
}