nus-yam/ex-repair huggingface dataset:
Program: 41204
Project: 41204
Buggy source:
/** 
 * Test that   {@link AmqpMessageIdHelper#toBaseMessageIdString(String)} throws an IAE if given an unexpected object type.
 */
@Test public void testToBaseMessageIdStringThrowsIAEWithUnexpectedType(){
  try {
    _messageIdHelper.toBaseMessageIdString(new Object());
    fail("String_Node_Str");
  }
 catch (  IllegalArgumentException iae) {
  }
}

Fixed version (ground truth):
/** 
 * Test that   {@link AmqpMessageIdHelper#toBaseMessageIdString(Object)} throws an IAE if given an unexpected object type.
 */
@Test public void testToBaseMessageIdStringThrowsIAEWithUnexpectedType(){
  try {
    _messageIdHelper.toBaseMessageIdString(new Object());
    fail("String_Node_Str");
  }
 catch (  IllegalArgumentException iae) {
  }
}
Program: 41205
Project: 41205
Buggy source:
/** 
 * Test that   {@link AmqpMessageIdHelper#toBaseMessageIdString(String)} returns a stringindicating an AMQP encoded UUID when given a UUID object.
 */
@Test public void testToBaseMessageIdStringWithUUID(){
  UUID uuidMessageId=UUID.randomUUID();
  String expected=AmqpMessageIdHelper.AMQP_UUID_PREFIX + uuidMessageId.toString();
  String baseMessageIdString=_messageIdHelper.toBaseMessageIdString(uuidMessageId);
  assertNotNull("String_Node_Str",baseMessageIdString);
  assertEquals("String_Node_Str",expected,baseMessageIdString);
}

Fixed version (ground truth):
/** 
 * Test that   {@link AmqpMessageIdHelper#toBaseMessageIdString(Object)} returns a stringindicating an AMQP encoded UUID when given a UUID object.
 */
@Test public void testToBaseMessageIdStringWithUUID(){
  UUID uuidMessageId=UUID.randomUUID();
  String expected=AmqpMessageIdHelper.AMQP_UUID_PREFIX + uuidMessageId.toString();
  String baseMessageIdString=_messageIdHelper.toBaseMessageIdString(uuidMessageId);
  assertNotNull("String_Node_Str",baseMessageIdString);
  assertEquals("String_Node_Str",expected,baseMessageIdString);
}
Program: 41206
Project: 41206
Buggy source:
/** 
 * Test that   {@link AmqpMessageIdHelper#toBaseMessageIdString(String)} returns a stringindicating an AMQP encoded string, when the given string happens to already begin with the  {@link AmqpMessageIdHelper#AMQP_ULONG_PREFIX}.
 */
@Test public void testToBaseMessageIdStringWithStringBeginningWithEncodingPrefixForLong(){
  String longStringMessageId=AmqpMessageIdHelper.AMQP_ULONG_PREFIX + Long.valueOf(123456789L);
  String expected=AmqpMessageIdHelper.AMQP_STRING_PREFIX + longStringMessageId;
  String baseMessageIdString=_messageIdHelper.toBaseMessageIdString(longStringMessageId);
  assertNotNull("String_Node_Str",baseMessageIdString);
  assertEquals("String_Node_Str",expected,baseMessageIdString);
}

Fixed version (ground truth):
/** 
 * Test that   {@link AmqpMessageIdHelper#toBaseMessageIdString(Object)} returns a stringindicating an AMQP encoded string, when the given string happens to already begin with the  {@link AmqpMessageIdHelper#AMQP_ULONG_PREFIX}.
 */
@Test public void testToBaseMessageIdStringWithStringBeginningWithEncodingPrefixForLong(){
  String longStringMessageId=AmqpMessageIdHelper.AMQP_ULONG_PREFIX + Long.valueOf(123456789L);
  String expected=AmqpMessageIdHelper.AMQP_STRING_PREFIX + longStringMessageId;
  String baseMessageIdString=_messageIdHelper.toBaseMessageIdString(longStringMessageId);
  assertNotNull("String_Node_Str",baseMessageIdString);
  assertEquals("String_Node_Str",expected,baseMessageIdString);
}
Program: 41207
Project: 41207
Buggy source:
/** 
 * Test that   {@link AmqpMessageIdHelper#toBaseMessageIdString(String)} returns a stringindicating an AMQP encoded string (effectively twice), when the given string happens to already begin with the  {@link AmqpMessageIdHelper#AMQP_STRING_PREFIX}.
 */
@Test public void testToBaseMessageIdStringWithStringBeginningWithEncodingPrefixForString(){
  String stringMessageId=AmqpMessageIdHelper.AMQP_STRING_PREFIX + "String_Node_Str";
  String expected=AmqpMessageIdHelper.AMQP_STRING_PREFIX + stringMessageId;
  String baseMessageIdString=_messageIdHelper.toBaseMessageIdString(stringMessageId);
  assertNotNull("String_Node_Str",baseMessageIdString);
  assertEquals("String_Node_Str",expected,baseMessageIdString);
}

Fixed version (ground truth):
/** 
 * Test that   {@link AmqpMessageIdHelper#toBaseMessageIdString(Object)} returns a stringindicating an AMQP encoded string (effectively twice), when the given string happens to already begin with the  {@link AmqpMessageIdHelper#AMQP_STRING_PREFIX}.
 */
@Test public void testToBaseMessageIdStringWithStringBeginningWithEncodingPrefixForString(){
  String stringMessageId=AmqpMessageIdHelper.AMQP_STRING_PREFIX + "String_Node_Str";
  String expected=AmqpMessageIdHelper.AMQP_STRING_PREFIX + stringMessageId;
  String baseMessageIdString=_messageIdHelper.toBaseMessageIdString(stringMessageId);
  assertNotNull("String_Node_Str",baseMessageIdString);
  assertEquals("String_Node_Str",expected,baseMessageIdString);
}
Program: 41208
Project: 41208
Buggy source:
/** 
 * Test that   {@link AmqpMessageIdHelper#toBaseMessageIdString(String)} returns null if given null
 */
@Test public void testToBaseMessageIdStringWithNull(){
  String nullString=null;
  assertNull("String_Node_Str",_messageIdHelper.toBaseMessageIdString(nullString));
}

Fixed version (ground truth):
/** 
 * Test that   {@link AmqpMessageIdHelper#toBaseMessageIdString(Object)} returns null if given null
 */
@Test public void testToBaseMessageIdStringWithNull(){
  String nullString=null;
  assertNull("String_Node_Str",_messageIdHelper.toBaseMessageIdString(nullString));
}
Program: 41209
Project: 41209
Buggy source:
@Ignore @Test(timeout=60000) public void testAnonymousSendToTopic() throws Exception {
  connection=createAmqpConnection();
  assertNotNull(connection);
  connection.start();
  Session session=connection.createSession(false,Session.AUTO_ACKNOWLEDGE);
  Topic topic=session.createTopic(name.getMethodName());
  assertNotNull(session);
  MessageProducer producer=session.createProducer(null);
  assertNotNull(producer);
  MessageConsumer consumer=session.createConsumer(topic);
  assertNotNull(consumer);
  Message message=session.createMessage();
  producer.send(topic,message);
  TopicViewMBean proxy=getProxyToTopic(name.getMethodName());
  assertEquals(1,proxy.getEnqueueCount());
}

Fixed version (ground truth):
@Test(timeout=60000) public void testAnonymousSendToTopic() throws Exception {
  connection=createAmqpConnection();
  assertNotNull(connection);
  connection.start();
  Session session=connection.createSession(false,Session.AUTO_ACKNOWLEDGE);
  Topic topic=session.createTopic(name.getMethodName());
  assertNotNull(session);
  MessageProducer producer=session.createProducer(null);
  assertNotNull(producer);
  MessageConsumer consumer=session.createConsumer(topic);
  assertNotNull(consumer);
  Message message=session.createMessage();
  producer.send(topic,message);
  TopicViewMBean proxy=getProxyToTopic(name.getMethodName());
  assertEquals(1,proxy.getEnqueueCount());
}
Program: 41210
Project: 41210
Buggy source:
protected void setConnectionIdGenerator(IdGenerator connectionIdGenerator){
  this.connectionIdGenerator=connectionIdGenerator;
}

Fixed version (ground truth):
protected synchronized void setConnectionIdGenerator(IdGenerator connectionIdGenerator){
  this.connectionIdGenerator=connectionIdGenerator;
}
Program: 41211
Project: 41211
Buggy source:
protected void setClientIdGenerator(IdGenerator clientIdGenerator){
  this.clientIdGenerator=clientIdGenerator;
}

Fixed version (ground truth):
protected synchronized void setClientIdGenerator(IdGenerator clientIdGenerator){
  this.clientIdGenerator=clientIdGenerator;
}
Program: 41212
Project: 41212
Buggy source:
/** 
 * Sets the prefix used by auto-generated JMS Client ID values which are used if the JMS client does not explicitly specify on.
 * @param clientIDPrefix
 */
public void setClientIDPrefix(String clientIDPrefix){
  this.clientIDPrefix=clientIDPrefix;
}

Fixed version (ground truth):
/** 
 * Sets the prefix used by auto-generated JMS Client ID values which are used if the JMS client does not explicitly specify on.
 * @param clientIDPrefix
 */
public synchronized void setClientIDPrefix(String clientIDPrefix){
  this.clientIDPrefix=clientIDPrefix;
}
Program: 41213
Project: 41213
Buggy source:
public String getClientIDPrefix(){
  return clientIDPrefix;
}

Fixed version (ground truth):
public synchronized String getClientIDPrefix(){
  return clientIDPrefix;
}
Program: 41214
Project: 41214
Buggy source:
/** 
 * Sets the prefix used by connection id generator.
 * @param connectionIDPrefix The string prefix used on all connection Id's created by this factory.
 */
public void setConnectionIDPrefix(String connectionIDPrefix){
  this.connectionIDPrefix=connectionIDPrefix;
}

Fixed version (ground truth):
/** 
 * Sets the prefix used by connection id generator.
 * @param connectionIDPrefix The string prefix used on all connection Id's created by this factory.
 */
public synchronized void setConnectionIDPrefix(String connectionIDPrefix){
  this.connectionIDPrefix=connectionIDPrefix;
}
Program: 41215
Project: 41215
Buggy source:
@Override public void close(){
  if (closed.compareAndSet(false,true)) {
    final ProviderFuture request=new ProviderFuture();
    serializer.execute(new Runnable(){
      @Override public void run(){
        try {
          if (!transport.isConnected()) {
            request.onSuccess();
          }
          if (connection != null) {
            connection.close(request);
          }
 else {
            request.onSuccess();
          }
          pumpToProtonTransport();
        }
 catch (        Exception e) {
          LOG.debug("String_Node_Str");
        }
      }
    }
);
    try {
      if (closeTimeout < 0) {
        request.sync();
      }
 else {
        request.sync(closeTimeout,TimeUnit.MILLISECONDS);
      }
    }
 catch (    IOException e) {
      LOG.warn("String_Node_Str",e.getMessage());
    }
 finally {
      if (transport != null) {
        try {
          transport.close();
        }
 catch (        Exception e) {
          LOG.debug("String_Node_Str",e.getMessage());
        }
      }
      if (serializer != null) {
        serializer.shutdown();
      }
    }
  }
}

Fixed version (ground truth):
@Override public void close(){
  if (closed.compareAndSet(false,true)) {
    final ProviderFuture request=new ProviderFuture();
    serializer.execute(new Runnable(){
      @Override public void run(){
        try {
          if (!transport.isConnected()) {
            request.onSuccess();
          }
          if (connection != null) {
            connection.close(request);
          }
 else {
            request.onSuccess();
          }
          pumpToProtonTransport();
        }
 catch (        Exception e) {
          LOG.debug("String_Node_Str");
        }
      }
    }
);
    try {
      if (closeTimeout < 0) {
        request.sync();
      }
 else {
        request.sync(closeTimeout,TimeUnit.MILLISECONDS);
      }
    }
 catch (    IOException e) {
      LOG.warn("String_Node_Str",e.getMessage());
    }
 finally {
      if (transport != null) {
        try {
          transport.close();
        }
 catch (        Exception e) {
          LOG.debug("String_Node_Str",e.getMessage());
        }
      }
      serializer.shutdown();
    }
  }
}
Program: 41216
Project: 41216
Buggy source:
/** 
 * Get properties from a uri
 * @param uri
 * @return <Code>Map</Code> of properties
 * @throws Exception
 */
public static Map<String,String> parseQuery(String uri) throws Exception {
  if (uri != null) {
    Map<String,String> rc=new HashMap<String,String>();
    if (uri != null) {
      String[] parameters=uri.split("String_Node_Str");
      for (int i=0; i < parameters.length; i++) {
        int p=parameters[i].indexOf("String_Node_Str");
        if (p >= 0) {
          String name=URLDecoder.decode(parameters[i].substring(0,p),"String_Node_Str");
          String value=URLDecoder.decode(parameters[i].substring(p + 1),"String_Node_Str");
          rc.put(name,value);
        }
 else {
          rc.put(parameters[i],null);
        }
      }
    }
    return rc;
  }
  return Collections.emptyMap();
}

Fixed version (ground truth):
/** 
 * Get properties from a uri
 * @param uri
 * @return <Code>Map</Code> of properties
 * @throws Exception
 */
public static Map<String,String> parseQuery(String uri) throws Exception {
  if (uri != null) {
    Map<String,String> rc=new HashMap<String,String>();
    String[] parameters=uri.split("String_Node_Str");
    for (int i=0; i < parameters.length; i++) {
      int p=parameters[i].indexOf("String_Node_Str");
      if (p >= 0) {
        String name=URLDecoder.decode(parameters[i].substring(0,p),"String_Node_Str");
        String value=URLDecoder.decode(parameters[i].substring(p + 1),"String_Node_Str");
        rc.put(name,value);
      }
 else {
        rc.put(parameters[i],null);
      }
    }
    return rc;
  }
  return Collections.emptyMap();
}
Program: 41217
Project: 41217
Buggy source:
@Override public boolean equals(Object o){
  ConversionKey x=(ConversionKey)o;
  return x.from == from && x.to == to;
}

Fixed version (ground truth):
@Override public boolean equals(Object o){
  if (this == o) {
    return true;
  }
  if (o == null || o.getClass() != this.getClass()) {
    return false;
  }
  ConversionKey x=(ConversionKey)o;
  return x.from == from && x.to == to;
}
Program: 41218
Project: 41218
Buggy source:
static public Class loadClass(Properties properties) throws ClassNotFoundException, IOException {
  String className=properties.getProperty("String_Node_Str");
  if (className == null) {
    throw new IOException("String_Node_Str");
  }
  Class clazz=null;
  ClassLoader loader=Thread.currentThread().getContextClassLoader();
  if (loader != null) {
    try {
      clazz=loader.loadClass(className);
    }
 catch (    ClassNotFoundException e) {
    }
  }
  if (clazz == null) {
    clazz=FactoryFinder.class.getClassLoader().loadClass(className);
  }
  return clazz;
}

Fixed version (ground truth):
static public Class<?> loadClass(Properties properties) throws ClassNotFoundException, IOException {
  String className=properties.getProperty("String_Node_Str");
  if (className == null) {
    throw new IOException("String_Node_Str");
  }
  Class<?> clazz=null;
  ClassLoader loader=Thread.currentThread().getContextClassLoader();
  if (loader != null) {
    try {
      clazz=loader.loadClass(className);
    }
 catch (    ClassNotFoundException e) {
    }
  }
  if (clazz == null) {
    clazz=FactoryFinder.class.getClassLoader().loadClass(className);
  }
  return clazz;
}
Program: 41219
Project: 41219
Buggy source:
@Override public Object create(final String path) throws InstantiationException, IllegalAccessException, ClassNotFoundException, IOException {
  Class clazz=classMap.get(path);
  if (clazz == null) {
    clazz=loadClass(loadProperties(path));
    classMap.put(path,clazz);
  }
  return clazz.newInstance();
}

Fixed version (ground truth):
@Override public Object create(final String path) throws InstantiationException, IllegalAccessException, ClassNotFoundException, IOException {
  Class<?> clazz=classMap.get(path);
  if (clazz == null) {
    clazz=loadClass(loadProperties(path));
    Class<?> previous=classMap.putIfAbsent(path,clazz);
    if (previous != null) {
      clazz=previous;
    }
  }
  return clazz.newInstance();
}
Program: 41220
Project: 41220
Buggy source:
/** 
 * Creates a new instance of the given key.  The method first checks the cache of previously found factory instances for one that matches the key.  If no cached version exists then the factory will be searched for using the configured ObjectFactory instance.
 * @param key is the key to add to the path to find a text file containing the factory name
 * @return a newly created instance
 * @throws IllegalAccessException if an error occurs while accessing the search path.
 * @throws InstantiationException if the factory object fails on create.
 * @throws IOException if the search encounter an IO error.
 * @throws ClassNotFoundException if the class that is to be loaded cannot be found.
 * @throws ClassCastException if the found object is not assignable to the request factory type.
 */
public T newInstance(String key) throws IllegalAccessException, InstantiationException, IOException, ClassNotFoundException, ClassCastException {
  T factory=cachedFactories.get(key);
  if (factory == null) {
    Object found=objectFactory.create(path + key);
    if (found != null && factoryType.isInstance(found)) {
      factory=factoryType.cast(found);
      cachedFactories.put(key,factory);
    }
 else {
      throw new ClassCastException("String_Node_Str" + found.getClass().getName() + "String_Node_Str"+ factoryType.getName());
    }
  }
  return factory;
}

Fixed version (ground truth):
/** 
 * Creates a new instance of the given key.  The method first checks the cache of previously found factory instances for one that matches the key.  If no cached version exists then the factory will be searched for using the configured ObjectFactory instance.
 * @param key is the key to add to the path to find a text file containing the factory name
 * @return a newly created instance
 * @throws IllegalAccessException if an error occurs while accessing the search path.
 * @throws InstantiationException if the factory object fails on create.
 * @throws IOException if the search encounter an IO error.
 * @throws ClassNotFoundException if the class that is to be loaded cannot be found.
 * @throws ClassCastException if the found object is not assignable to the request factory type.
 */
public T newInstance(String key) throws IllegalAccessException, InstantiationException, IOException, ClassNotFoundException, ClassCastException {
  T factory=cachedFactories.get(key);
  if (factory == null) {
    Object found=objectFactory.create(path + key);
    if (found != null) {
      if (factoryType.isInstance(found)) {
        factory=factoryType.cast(found);
        cachedFactories.putIfAbsent(key,factory);
      }
 else {
        throw new ClassCastException("String_Node_Str" + found.getClass().getName() + "String_Node_Str"+ factoryType.getName());
      }
    }
 else {
      throw new ClassNotFoundException("String_Node_Str" + key);
    }
  }
  return factory;
}
Program: 41221
Project: 41221
Buggy source:
static public Properties loadProperties(String uri) throws IOException {
  ClassLoader classLoader=Thread.currentThread().getContextClassLoader();
  if (classLoader == null) {
    classLoader=StandaloneObjectFactory.class.getClassLoader();
  }
  InputStream in=classLoader.getResourceAsStream(uri);
  if (in == null) {
    in=FactoryFinder.class.getClassLoader().getResourceAsStream(uri);
    if (in == null) {
      throw new IOException("String_Node_Str" + uri);
    }
  }
  BufferedInputStream reader=null;
  try {
    reader=new BufferedInputStream(in);
    Properties properties=new Properties();
    properties.load(reader);
    return properties;
  }
  finally {
    try {
      reader.close();
    }
 catch (    Exception e) {
    }
  }
}

Fixed version (ground truth):
static public Properties loadProperties(String uri) throws IOException {
  ClassLoader classLoader=Thread.currentThread().getContextClassLoader();
  if (classLoader == null) {
    classLoader=StandaloneObjectFactory.class.getClassLoader();
  }
  InputStream in=classLoader.getResourceAsStream(uri);
  if (in == null) {
    in=FactoryFinder.class.getClassLoader().getResourceAsStream(uri);
    if (in == null) {
      throw new IOException("String_Node_Str" + uri);
    }
  }
  try (BufferedInputStream reader=new BufferedInputStream(in)){
    Properties properties=new Properties();
    properties.load(reader);
    return properties;
  }
 }
Program: 41222
Project: 41222
Buggy source:
@Override public boolean equals(Object object){
  if (object instanceof JmsPrefetchPolicy) {
    JmsPrefetchPolicy other=(JmsPrefetchPolicy)object;
    return this.queuePrefetch == other.queuePrefetch && this.queueBrowserPrefetch == other.queueBrowserPrefetch && this.topicPrefetch == other.topicPrefetch && this.durableTopicPrefetch == other.durableTopicPrefetch;
  }
  return false;
}

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;
  }
  JmsPrefetchPolicy other=(JmsPrefetchPolicy)obj;
  return this.queuePrefetch == other.queuePrefetch && this.queueBrowserPrefetch == other.queueBrowserPrefetch && this.topicPrefetch == other.topicPrefetch && this.durableTopicPrefetch == other.durableTopicPrefetch;
}
Program: 41223
Project: 41223
Buggy source:
@Override public int hashCode(){
  return this.connectionId.hashCode();
}

Fixed version (ground truth):
@Override public int hashCode(){
  return (connectionId == null) ? super.hashCode() : connectionId.hashCode();
}
Program: 41224
Project: 41224
Buggy source:
@Override public boolean equals(Object obj){
  if (this == obj) {
    return true;
  }
  if (obj == null) {
    return false;
  }
  if (getClass() != obj.getClass()) {
    return false;
  }
  JmsConnectionInfo other=(JmsConnectionInfo)obj;
  if (connectionId == null && other.connectionId != null) {
    return false;
  }
 else   if (!connectionId.equals(other.connectionId)) {
    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;
  }
  JmsConnectionInfo other=(JmsConnectionInfo)obj;
  if (connectionId != null) {
    return connectionId.equals(other.connectionId);
  }
  return false;
}
Program: 41225
Project: 41225
Buggy source:
@Override public int hashCode(){
  return (consumerId == null) ? 0 : consumerId.hashCode();
}

Fixed version (ground truth):
@Override public int hashCode(){
  return (consumerId == null) ? super.hashCode() : consumerId.hashCode();
}
Program: 41226
Project: 41226
Buggy source:
@Override public boolean equals(Object obj){
  if (this == obj) {
    return true;
  }
  if (obj == null) {
    return false;
  }
  if (getClass() != obj.getClass()) {
    return false;
  }
  JmsConsumerInfo other=(JmsConsumerInfo)obj;
  if (consumerId == null && other.consumerId != null) {
    return false;
  }
 else   if (!consumerId.equals(other.consumerId)) {
    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;
  }
  JmsConsumerInfo other=(JmsConsumerInfo)obj;
  if (consumerId != null) {
    return consumerId.equals(other.consumerId);
  }
  return false;
}
Program: 41227
Project: 41227
Buggy source:
@Override public int hashCode(){
  return (producerId == null) ? 0 : producerId.hashCode();
}

Fixed version (ground truth):
@Override public int hashCode(){
  return (producerId == null) ? super.hashCode() : producerId.hashCode();
}
Program: 41228
Project: 41228
Buggy source:
@Override public boolean equals(Object obj){
  if (this == obj) {
    return true;
  }
  if (obj == null) {
    return false;
  }
  if (getClass() != obj.getClass()) {
    return false;
  }
  JmsProducerInfo other=(JmsProducerInfo)obj;
  if (producerId == null && other.producerId != null) {
    return false;
  }
 else   if (!producerId.equals(other.producerId)) {
    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;
  }
  JmsProducerInfo other=(JmsProducerInfo)obj;
  if (producerId != null) {
    return producerId.equals(other.producerId);
  }
  return false;
}
Program: 41229
Project: 41229
Buggy source:
@Override public int hashCode(){
  return (transactionId == null) ? 0 : transactionId.hashCode();
}

Fixed version (ground truth):
@Override public int hashCode(){
  return (transactionId == null) ? super.hashCode() : transactionId.hashCode();
}
Program: 41230
Project: 41230
Buggy source:
@Override public boolean equals(Object obj){
  if (this == obj) {
    return true;
  }
  if (obj == null) {
    return false;
  }
  if (getClass() != obj.getClass()) {
    return false;
  }
  JmsTransactionInfo other=(JmsTransactionInfo)obj;
  if (transactionId == null && other.transactionId != null) {
    return false;
  }
 else   if (!transactionId.equals(other.transactionId)) {
    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;
  }
  JmsTransactionInfo other=(JmsTransactionInfo)obj;
  if (transactionId != null) {
    return transactionId.equals(other.transactionId);
  }
  return false;
}
Program: 41231
Project: 41231
Buggy source:
/** 
 * @return clientId
 * @see javax.jms.Connection#getClientID()
 */
@Override public String getClientID() throws JMSException {
  checkClosedOrFailed();
  return this.connectionInfo.getClientId();
}

Fixed version (ground truth):
/** 
 * @return clientId
 * @see javax.jms.Connection#getClientID()
 */
@Override public synchronized String getClientID() throws JMSException {
  checkClosedOrFailed();
  return this.connectionInfo.getClientId();
}
Program: 41232
Project: 41232
Buggy source:
/** 
 * Called to free all Connection resources.
 */
protected void shutdown() throws JMSException {
  for (  JmsSession session : this.sessions) {
    session.shutdown();
  }
  if (isConnected() && !failed.get() && !closing.get()) {
    destroyResource(connectionInfo);
  }
  if (clientIdSet) {
    connectionInfo.setClientId(null);
    clientIdSet=false;
  }
  tempDestinations.clear();
  started.set(false);
  connected.set(false);
}

Fixed version (ground truth):
/** 
 * Called to free all Connection resources.
 */
protected void shutdown() throws JMSException {
  for (  JmsSession session : this.sessions) {
    session.shutdown();
  }
  if (isConnected() && !failed.get() && !closing.get()) {
    destroyResource(connectionInfo);
  }
synchronized (this) {
    if (clientIdSet) {
      connectionInfo.setClientId(null);
      clientIdSet=false;
    }
  }
  tempDestinations.clear();
  started.set(false);
  connected.set(false);
}
Program: 41233
Project: 41233
Buggy source:
@Override public byte[] getBytes(String name) throws JMSException {
  Object value=getObject(name);
  if (value == null) {
    return (byte[])value;
  }
 else   if (value instanceof byte[]) {
    byte[] original=(byte[])value;
    byte[] clone=new byte[original.length];
    System.arraycopy(original,0,clone,0,original.length);
    return clone;
  }
 else {
    throw new MessageFormatException("String_Node_Str" + value.getClass().getSimpleName());
  }
}

Fixed version (ground truth):
@Override public byte[] getBytes(String name) throws JMSException {
  Object value=getObject(name);
  if (value == null) {
    return null;
  }
 else   if (value instanceof byte[]) {
    byte[] original=(byte[])value;
    byte[] clone=new byte[original.length];
    System.arraycopy(original,0,clone,0,original.length);
    return clone;
  }
 else {
    throw new MessageFormatException("String_Node_Str" + value.getClass().getSimpleName());
  }
}
Program: 41234
Project: 41234
Buggy source:
@Override protected void doOpen(){
  JmsDestination destination=info.getDestination();
  String destnationName=session.getQualifiedName(destination);
  String sourceAddress=getProducerId().toString();
  Source source=new Source();
  source.setAddress(sourceAddress);
  Target target=new Target();
  target.setAddress(destnationName);
  String senderName=sourceAddress + "String_Node_Str" + destnationName != null ? destnationName : "String_Node_Str";
  endpoint=session.getProtonSession().sender(senderName);
  endpoint.setSource(source);
  endpoint.setTarget(target);
  if (presettle) {
    endpoint.setSenderSettleMode(SenderSettleMode.SETTLED);
  }
 else {
    endpoint.setSenderSettleMode(SenderSettleMode.UNSETTLED);
  }
  endpoint.setReceiverSettleMode(ReceiverSettleMode.FIRST);
}

Fixed version (ground truth):
@Override protected void doOpen(){
  JmsDestination destination=info.getDestination();
  String destnationName=session.getQualifiedName(destination);
  String sourceAddress=getProducerId().toString();
  Source source=new Source();
  source.setAddress(sourceAddress);
  Target target=new Target();
  target.setAddress(destnationName);
  String senderName=sourceAddress + "String_Node_Str" + destnationName;
  endpoint=session.getProtonSession().sender(senderName);
  endpoint.setSource(source);
  endpoint.setTarget(target);
  if (presettle) {
    endpoint.setSenderSettleMode(SenderSettleMode.SETTLED);
  }
 else {
    endpoint.setSenderSettleMode(SenderSettleMode.UNSETTLED);
  }
  endpoint.setReceiverSettleMode(ReceiverSettleMode.FIRST);
}
Program: 41235
Project: 41235
Buggy source:
private Binary getBinaryFromBody(){
  Section body=getAmqpMessage().getBody();
  Binary result=null;
  if (body == null) {
    return result;
  }
  if (body instanceof Data) {
    Binary payload=((Data)body).getValue();
    if (payload != null && payload.getLength() != 0) {
      result=payload;
    }
  }
 else   if (body instanceof AmqpValue) {
    Object value=((AmqpValue)body).getValue();
    if (value == null) {
      return result;
    }
    if (value instanceof Binary) {
      Binary payload=(Binary)value;
      if (payload != null && payload.getLength() != 0) {
        result=payload;
      }
    }
 else {
      throw new IllegalStateException("String_Node_Str" + value.getClass().getSimpleName());
    }
  }
 else {
    throw new IllegalStateException("String_Node_Str" + body.getClass().getSimpleName());
  }
  return result;
}

Fixed version (ground truth):
private Binary getBinaryFromBody(){
  Section body=getAmqpMessage().getBody();
  Binary result=null;
  if (body == null) {
    return result;
  }
  if (body instanceof Data) {
    Binary payload=((Data)body).getValue();
    if (payload != null && payload.getLength() != 0) {
      result=payload;
    }
  }
 else   if (body instanceof AmqpValue) {
    Object value=((AmqpValue)body).getValue();
    if (value == null) {
      return result;
    }
    if (value instanceof Binary) {
      Binary payload=(Binary)value;
      if (payload.getLength() != 0) {
        result=payload;
      }
    }
 else {
      throw new IllegalStateException("String_Node_Str" + value.getClass().getSimpleName());
    }
  }
 else {
    throw new IllegalStateException("String_Node_Str" + body.getClass().getSimpleName());
  }
  return result;
}
Program: 41236
Project: 41236
Buggy source:
@Override public void setCorrelationId(String correlationId){
  AmqpMessageIdHelper messageIdHelper=AmqpMessageIdHelper.INSTANCE;
  if (correlationId == null) {
    message.setCorrelationId(null);
  }
 else {
    boolean appSpecific=false;
    boolean hasMessageIdPrefix=messageIdHelper.hasMessageIdPrefix(correlationId);
    if (correlationId != null && !hasMessageIdPrefix) {
      appSpecific=true;
    }
    String stripped=messageIdHelper.stripMessageIdPrefix(correlationId);
    if (hasMessageIdPrefix) {
      try {
        Object idObject=messageIdHelper.toIdObject(stripped);
        message.setCorrelationId(idObject);
      }
 catch (      IdConversionException e) {
        throw new RuntimeException(e);
      }
    }
 else {
      message.setCorrelationId(stripped);
    }
    if (appSpecific) {
      setAnnotation(AmqpMessageSupport.JMS_APP_CORRELATION_ID,true);
    }
 else {
      removeAnnotation(AmqpMessageSupport.JMS_APP_CORRELATION_ID);
    }
  }
}

Fixed version (ground truth):
@Override public void setCorrelationId(String correlationId){
  AmqpMessageIdHelper messageIdHelper=AmqpMessageIdHelper.INSTANCE;
  if (correlationId == null) {
    message.setCorrelationId(null);
  }
 else {
    boolean appSpecific=false;
    boolean hasMessageIdPrefix=messageIdHelper.hasMessageIdPrefix(correlationId);
    if (!hasMessageIdPrefix) {
      appSpecific=true;
    }
    String stripped=messageIdHelper.stripMessageIdPrefix(correlationId);
    if (hasMessageIdPrefix) {
      try {
        Object idObject=messageIdHelper.toIdObject(stripped);
        message.setCorrelationId(idObject);
      }
 catch (      IdConversionException e) {
        throw new RuntimeException(e);
      }
    }
 else {
      message.setCorrelationId(stripped);
    }
    if (appSpecific) {
      setAnnotation(AmqpMessageSupport.JMS_APP_CORRELATION_ID,true);
    }
 else {
      removeAnnotation(AmqpMessageSupport.JMS_APP_CORRELATION_ID);
    }
  }
}
Program: 41237
Project: 41237
Buggy source:
/** 
 * Given a key / value mapping, create and return a URI formatted query string that is valid and can be appended to a URI.
 * @param options The Mapping that will create the new Query string.
 * @return a URI formatted query string.
 * @throws URISyntaxException
 */
public static String createQueryString(Map<String,? extends Object> options) throws URISyntaxException {
  try {
    if (options.size() > 0) {
      StringBuffer rc=new StringBuffer();
      boolean first=true;
      for (      String key : options.keySet()) {
        if (first) {
          first=false;
        }
 else {
          rc.append("String_Node_Str");
        }
        String value=(String)options.get(key);
        rc.append(URLEncoder.encode(key,"String_Node_Str"));
        rc.append("String_Node_Str");
        rc.append(URLEncoder.encode(value,"String_Node_Str"));
      }
      return rc.toString();
    }
 else {
      return "String_Node_Str";
    }
  }
 catch (  UnsupportedEncodingException e) {
    throw (URISyntaxException)new URISyntaxException(e.toString(),"String_Node_Str").initCause(e);
  }
}

Fixed version (ground truth):
/** 
 * Given a key / value mapping, create and return a URI formatted query string that is valid and can be appended to a URI.
 * @param options The Mapping that will create the new Query string.
 * @return a URI formatted query string.
 * @throws URISyntaxException
 */
public static String createQueryString(Map<String,? extends Object> options) throws URISyntaxException {
  try {
    if (options.size() > 0) {
      StringBuffer rc=new StringBuffer();
      boolean first=true;
      for (      Entry<String,? extends Object> entry : options.entrySet()) {
        if (first) {
          first=false;
        }
 else {
          rc.append("String_Node_Str");
        }
        rc.append(URLEncoder.encode(entry.getKey(),"String_Node_Str"));
        rc.append("String_Node_Str");
        rc.append(URLEncoder.encode((String)entry.getValue(),"String_Node_Str"));
      }
      return rc.toString();
    }
 else {
      return "String_Node_Str";
    }
  }
 catch (  UnsupportedEncodingException e) {
    throw (URISyntaxException)new URISyntaxException(e.toString(),"String_Node_Str").initCause(e);
  }
}
Program: 41238
Project: 41238
Buggy source:
/** 
 * Given a map of properties, filter out only those prefixed with the given value, the values filtered are returned in a new Map instance.
 * @param properties The map of properties to filter.
 * @param optionPrefix The prefix value to use when filtering.
 * @return a filter map with only values that match the given prefix.
 */
public static Map<String,String> filterProperties(Map<String,String> props,String optionPrefix){
  if (props == null) {
    throw new IllegalArgumentException("String_Node_Str");
  }
  HashMap<String,String> rc=new HashMap<String,String>(props.size());
  for (Iterator<String> iter=props.keySet().iterator(); iter.hasNext(); ) {
    String name=iter.next();
    if (name.startsWith(optionPrefix)) {
      String value=props.get(name);
      name=name.substring(optionPrefix.length());
      rc.put(name,value);
      iter.remove();
    }
  }
  return rc;
}

Fixed version (ground truth):
/** 
 * Given a map of properties, filter out only those prefixed with the given value, the values filtered are returned in a new Map instance.
 * @param properties The map of properties to filter.
 * @param optionPrefix The prefix value to use when filtering.
 * @return a filter map with only values that match the given prefix.
 */
public static Map<String,String> filterProperties(Map<String,String> props,String optionPrefix){
  if (props == null) {
    throw new IllegalArgumentException("String_Node_Str");
  }
  HashMap<String,String> rc=new HashMap<String,String>(props.size());
  for (Iterator<Entry<String,String>> iter=props.entrySet().iterator(); iter.hasNext(); ) {
    Entry<String,String> entry=iter.next();
    if (entry.getKey().startsWith(optionPrefix)) {
      String name=entry.getKey().substring(optionPrefix.length());
      rc.put(name,entry.getValue());
      iter.remove();
    }
  }
  return rc;
}
Program: 41239
Project: 41239
Buggy source:
@SuppressWarnings({"String_Node_Str","String_Node_Str"}) public static String toString(Object target,Class stopClass,Map<String,Object> overrideFields){
  LinkedHashMap<String,Object> map=new LinkedHashMap<String,Object>();
  addFields(target,target.getClass(),stopClass,map);
  if (overrideFields != null) {
    for (    String key : overrideFields.keySet()) {
      Object value=overrideFields.get(key);
      map.put(key,value);
    }
  }
  StringBuffer buffer=new StringBuffer(simpleName(target.getClass()));
  buffer.append("String_Node_Str");
  Set<Entry<String,Object>> entrySet=map.entrySet();
  boolean first=true;
  for (  Map.Entry<String,Object> entry : entrySet) {
    Object value=entry.getValue();
    Object key=entry.getKey();
    if (first) {
      first=false;
    }
 else {
      buffer.append("String_Node_Str");
    }
    buffer.append(key);
    buffer.append("String_Node_Str");
    appendToString(buffer,key,value);
  }
  buffer.append("String_Node_Str");
  return buffer.toString();
}

Fixed version (ground truth):
@SuppressWarnings({"String_Node_Str","String_Node_Str"}) public static String toString(Object target,Class stopClass,Map<String,Object> overrideFields){
  LinkedHashMap<String,Object> map=new LinkedHashMap<String,Object>();
  addFields(target,target.getClass(),stopClass,map);
  if (overrideFields != null) {
    for (    Entry<String,Object> entry : overrideFields.entrySet()) {
      map.put(entry.getKey(),entry.getValue());
    }
  }
  StringBuffer buffer=new StringBuffer(simpleName(target.getClass()));
  buffer.append("String_Node_Str");
  Set<Entry<String,Object>> entrySet=map.entrySet();
  boolean first=true;
  for (  Map.Entry<String,Object> entry : entrySet) {
    Object value=entry.getValue();
    Object key=entry.getKey();
    if (first) {
      first=false;
    }
 else {
      buffer.append("String_Node_Str");
    }
    buffer.append(key);
    buffer.append("String_Node_Str");
    appendToString(buffer,key,value);
  }
  buffer.append("String_Node_Str");
  return buffer.toString();
}
Program: 41240
Project: 41240
Buggy source:
/** 
 * Creates a new Facade around an incoming AMQP Message for dispatch to the JMS Consumer instance.
 * @param consumer the consumer that received this message.
 * @param message the incoming Message instance that is being wrapped.
 */
@SuppressWarnings("String_Node_Str") public AmqpJmsMessageFacade(AmqpConsumer consumer,Message message){
  this.message=message;
  this.connection=consumer.getConnection();
  this.consumerDestination=consumer.getDestination();
  annotations=message.getMessageAnnotations();
  if (annotations != null) {
    annotationsMap=annotations.getValue();
  }
  if (message.getApplicationProperties() != null) {
    applicationPropertiesMap=message.getApplicationProperties().getValue();
  }
  Long ttl=message.getTtl();
  Long absoluteExpiryTime=getAbsoluteExpiryTime();
  if (absoluteExpiryTime == null && ttl != null) {
    syntheticExpiration=System.currentTimeMillis() + ttl;
  }
}

Fixed version (ground truth):
/** 
 * Creates a new Facade around an incoming AMQP Message for dispatch to the JMS Consumer instance.
 * @param consumer the consumer that received this message.
 * @param message the incoming Message instance that is being wrapped.
 */
@SuppressWarnings("String_Node_Str") public AmqpJmsMessageFacade(AmqpConsumer consumer,Message message){
  this.message=message;
  this.connection=consumer.getConnection();
  this.consumerDestination=consumer.getDestination();
  annotations=message.getMessageAnnotations();
  if (annotations != null) {
    annotationsMap=annotations.getValue();
  }
  if (message.getApplicationProperties() != null) {
    applicationPropertiesMap=message.getApplicationProperties().getValue();
  }
  Long ttl=getTtl();
  Long absoluteExpiryTime=getAbsoluteExpiryTime();
  if (absoluteExpiryTime == null && ttl != null) {
    syntheticExpiration=System.currentTimeMillis() + ttl;
  }
}
Program: 41242
Project: 41242
Buggy source:
/** 
 * Searches for a PacketParserFactory by using the given key. The search first checks the local cache of packet parser factories before moving on to search in the classpath.
 * @param key The name of the PacketParserFactory that should be located.
 * @return a PacketParserFactory instance matching the given key.
 * @throws IOException if an error occurs while locating the factory.
 */
protected static PacketParserFactory findAgentFactory(String key) throws IOException {
  if (key == null) {
    throw new IOException("String_Node_Str" + key + "String_Node_Str");
  }
  PacketParserFactory factory=null;
  if (factory == null) {
    try {
      factory=AGENT_FACTORY_FINDER.newInstance(key);
    }
 catch (    Throwable e) {
      throw new IOException("String_Node_Str" + key + "String_Node_Str",e);
    }
  }
  return factory;
}

Fixed version (ground truth):
/** 
 * Searches for a PacketParserFactory by using the given key. The search first checks the local cache of packet parser factories before moving on to search in the classpath.
 * @param key The name of the PacketParserFactory that should be located.
 * @return a PacketParserFactory instance matching the given key.
 * @throws IOException if an error occurs while locating the factory.
 */
protected static PacketParserFactory findAgentFactory(String key) throws IOException {
  if (key == null) {
    throw new IOException("String_Node_Str");
  }
  PacketParserFactory factory=null;
  if (factory == null) {
    try {
      factory=AGENT_FACTORY_FINDER.newInstance(key);
    }
 catch (    Throwable e) {
      throw new IOException("String_Node_Str" + key + "String_Node_Str",e);
    }
  }
  return factory;
}
Program: 41243
Project: 41243
Buggy source:
/** 
 * Check whether the content-type field of the properties section (if present) in the given message matches the provided string (where null matches if there is no content type rpeesnt.
 * @param contentType content type string to compare against, or null if none
 * @param message the AMQP message object that is being examined.
 * @return true if content type matches
 */
public static boolean isContentType(String contentType,Message message){
  if (contentType == null) {
    return message.getContentType() == null;
  }
 else {
    return contentType.equals(message.getContentType());
  }
}

Fixed version (ground truth):
/** 
 * Check whether the content-type field of the properties section (if present) in the given message matches the provided string (where null matches if there is no content type present.
 * @param contentType content type string to compare against, or null if none
 * @param message the AMQP message object that is being examined.
 * @return true if content type matches
 */
public static boolean isContentType(String contentType,Message message){
  if (contentType == null) {
    return message.getContentType() == null;
  }
 else {
    return contentType.equals(message.getContentType());
  }
}
Program: 41244
Project: 41244
Buggy source:
public void setReplyToAddressFromDestination(AmqpJmsMessageFacade message,JmsDestination destination){
  if (destination == null) {
    return;
  }
  String replyToAddress=destination.getName();
  String typeString=toTypeAnnotation(destination);
  message.setReplyToAddress(replyToAddress);
  if (replyToAddress == null || typeString == null) {
    message.removeAnnotation(REPLY_TO_TYPE_MSG_ANNOTATION_SYMBOL_NAME);
  }
 else {
    message.setAnnotation(REPLY_TO_TYPE_MSG_ANNOTATION_SYMBOL_NAME,typeString);
  }
}

Fixed version (ground truth):
public void setReplyToAddressFromDestination(AmqpJmsMessageFacade message,JmsDestination destination){
  String replyToAddress=destination != null ? destination.getName() : null;
  String typeString=toTypeAnnotation(destination);
  message.setReplyToAddress(replyToAddress);
  if (replyToAddress == null || typeString == null) {
    message.removeAnnotation(REPLY_TO_TYPE_MSG_ANNOTATION_SYMBOL_NAME);
  }
 else {
    message.setAnnotation(REPLY_TO_TYPE_MSG_ANNOTATION_SYMBOL_NAME,typeString);
  }
}
Program: 41245
Project: 41245
Buggy source:
public void setToAddressFromDestination(AmqpJmsMessageFacade message,JmsDestination destination){
  if (destination == null) {
    return;
  }
  String address=destination.getName();
  String typeString=toTypeAnnotation(destination);
  message.setToAddress(address);
  if (address == null || typeString == null) {
    message.removeAnnotation(TO_TYPE_MSG_ANNOTATION_SYMBOL_NAME);
  }
 else {
    message.setAnnotation(TO_TYPE_MSG_ANNOTATION_SYMBOL_NAME,typeString);
  }
}

Fixed version (ground truth):
public void setToAddressFromDestination(AmqpJmsMessageFacade message,JmsDestination destination){
  String address=destination != null ? destination.getName() : null;
  String typeString=toTypeAnnotation(destination);
  message.setToAddress(address);
  if (address == null || typeString == null) {
    message.removeAnnotation(TO_TYPE_MSG_ANNOTATION_SYMBOL_NAME);
  }
 else {
    message.setAnnotation(TO_TYPE_MSG_ANNOTATION_SYMBOL_NAME,typeString);
  }
}
Program: 41246
Project: 41246
Buggy source:
@Test public void testSetToAddressFromDestinationWithNullDestination(){
  AmqpJmsMessageFacade message=Mockito.mock(AmqpJmsMessageFacade.class);
  helper.setToAddressFromDestination(message,null);
  Mockito.verifyZeroInteractions(message);
}

Fixed version (ground truth):
@Test public void testSetToAddressFromDestinationWithNullDestination(){
  AmqpJmsMessageFacade message=Mockito.mock(AmqpJmsMessageFacade.class);
  helper.setToAddressFromDestination(message,null);
  Mockito.verify(message).setToAddress(null);
  Mockito.verify(message).removeAnnotation(TO_TYPE_MSG_ANNOTATION_SYMBOL_NAME);
}
Program: 41247
Project: 41247
Buggy source:
@Test public void testSetReplyToAddressFromDestinationWithNullDestinationAndNullMessage(){
  AmqpJmsMessageFacade message=Mockito.mock(AmqpJmsMessageFacade.class);
  helper.setReplyToAddressFromDestination(null,null);
  Mockito.verifyZeroInteractions(message);
}

Fixed version (ground truth):
@Test(expected=NullPointerException.class) public void testSetReplyToAddressFromDestinationWithNullDestinationAndNullMessage(){
  helper.setReplyToAddressFromDestination(null,null);
}
Program: 41248
Project: 41248
Buggy source:
@Test public void testSetReplyToAddressFromDestinationWithNullDestination(){
  AmqpJmsMessageFacade message=Mockito.mock(AmqpJmsMessageFacade.class);
  helper.setReplyToAddressFromDestination(message,null);
  Mockito.verifyZeroInteractions(message);
}

Fixed version (ground truth):
@Test public void testSetReplyToAddressFromDestinationWithNullDestination(){
  AmqpJmsMessageFacade message=Mockito.mock(AmqpJmsMessageFacade.class);
  helper.setReplyToAddressFromDestination(message,null);
  Mockito.verify(message).setReplyToAddress(null);
  Mockito.verify(message).removeAnnotation(REPLY_TO_TYPE_MSG_ANNOTATION_SYMBOL_NAME);
}
Program: 41249
Project: 41249
Buggy source:
@Test public void testSetToAddressFromDestinationWithNullDestinationAndNullMessage(){
  AmqpJmsMessageFacade message=Mockito.mock(AmqpJmsMessageFacade.class);
  helper.setToAddressFromDestination(null,null);
  Mockito.verifyZeroInteractions(message);
}

Fixed version (ground truth):
@Test(expected=NullPointerException.class) public void testSetToAddressFromDestinationWithNullDestinationAndNullMessage(){
  helper.setToAddressFromDestination(null,null);
}