nus-yam/ex-repair huggingface dataset:
Program: 49116
Project: 49116
Buggy source:
public static void shutdownAll(){
  MBeanServer mbs=ManagementFactory.getPlatformMBeanServer();
  try {
    Set<ObjectName> entries=mbs.queryNames(new ObjectName(HazelcastMBean.DOMAIN + "String_Node_Str"),null);
    for (    ObjectName name : entries) {
      if (mbs.isRegistered(name)) {
        mbs.unregisterMBean(name);
      }
    }
  }
 catch (  Exception e) {
    Logger.getLogger(ManagementService.class.getName()).log(Level.WARNING,"String_Node_Str",e);
  }
}

Fixed version (ground truth):
public static void shutdownAll(){
  MBeanServer mbs=ManagementFactory.getPlatformMBeanServer();
  try {
    Set<ObjectName> entries=mbs.queryNames(new ObjectName(DOMAIN + "String_Node_Str"),null);
    for (    ObjectName name : entries) {
      if (mbs.isRegistered(name)) {
        mbs.unregisterMBean(name);
      }
    }
  }
 catch (  Exception e) {
    Logger.getLogger(ManagementService.class.getName()).log(Level.WARNING,"String_Node_Str",e);
  }
}
Program: 49117
Project: 49117
Buggy source:
public void destroy(){
  if (!enabled) {
    return;
  }
  instance.removeDistributedObjectListener(registrationId);
  MBeanServer mbs=ManagementFactory.getPlatformMBeanServer();
  try {
    Set<ObjectName> entries=mbs.queryNames(new ObjectName(HazelcastMBean.DOMAIN + "String_Node_Str" + instance.getName()+ "String_Node_Str"),null);
    for (    ObjectName name : entries) {
      if (mbs.isRegistered(name)) {
        mbs.unregisterMBean(name);
      }
    }
  }
 catch (  Exception e) {
    logger.warning("String_Node_Str",e);
  }
}

Fixed version (ground truth):
public void destroy(){
  if (!enabled) {
    return;
  }
  instance.removeDistributedObjectListener(registrationId);
  MBeanServer mbs=ManagementFactory.getPlatformMBeanServer();
  try {
    Set<ObjectName> entries=mbs.queryNames(new ObjectName(DOMAIN + "String_Node_Str" + quote(instance.getName())+ "String_Node_Str"),null);
    for (    ObjectName name : entries) {
      if (mbs.isRegistered(name)) {
        mbs.unregisterMBean(name);
      }
    }
  }
 catch (  Exception e) {
    logger.warning("String_Node_Str",e);
  }
}
Program: 49118
Project: 49118
Buggy source:
private void unregisterDistributedObject(DistributedObject distributedObject){
  HazelcastMBean bean=createHazelcastBean(distributedObject);
  if (bean != null) {
    MBeanServer mbs=ManagementFactory.getPlatformMBeanServer();
    if (mbs.isRegistered(bean.objectName)) {
      try {
        mbs.unregisterMBean(bean.objectName);
      }
 catch (      Exception e) {
        logger.warning("String_Node_Str" + bean.objectName,e);
      }
    }
  }
}

Fixed version (ground truth):
private void unregisterDistributedObject(DistributedObject distributedObject){
  final String objectType=getObjectType(distributedObject);
  if (objectType != null) {
    ObjectName objectName=createObjectName(objectType,distributedObject.getName());
    MBeanServer mbs=ManagementFactory.getPlatformMBeanServer();
    if (mbs.isRegistered(objectName)) {
      try {
        mbs.unregisterMBean(objectName);
      }
 catch (      Exception e) {
        logger.warning("String_Node_Str" + objectName,e);
      }
    }
  }
}
Program: 49119
Project: 49119
Buggy source:
protected MapMBean(IMap managedObject,ManagementService service){
  super(managedObject,service);
  objectName=createObjectName("String_Node_Str",managedObject.getName());
  EntryListener entryListener=new EntryListener(){
    public void entryAdded(    EntryEvent event){
      totalAddedEntryCount.incrementAndGet();
    }
    public void entryRemoved(    EntryEvent event){
      totalRemovedEntryCount.incrementAndGet();
    }
    public void entryUpdated(    EntryEvent event){
      totalUpdatedEntryCount.incrementAndGet();
    }
    public void entryEvicted(    EntryEvent event){
      totalEvictedEntryCount.incrementAndGet();
    }
  }
;
  listenerId=managedObject.addEntryListener(entryListener,false);
}

Fixed version (ground truth):
protected MapMBean(IMap managedObject,ManagementService service){
  super(managedObject,service);
  objectName=service.createObjectName("String_Node_Str",managedObject.getName());
  EntryListener entryListener=new EntryListener(){
    public void entryAdded(    EntryEvent event){
      totalAddedEntryCount.incrementAndGet();
    }
    public void entryRemoved(    EntryEvent event){
      totalRemovedEntryCount.incrementAndGet();
    }
    public void entryUpdated(    EntryEvent event){
      totalUpdatedEntryCount.incrementAndGet();
    }
    public void entryEvicted(    EntryEvent event){
      totalEvictedEntryCount.incrementAndGet();
    }
  }
;
  listenerId=managedObject.addEntryListener(entryListener,false);
}
Program: 49120
Project: 49120
Buggy source:
protected MultiMapMBean(MultiMap managedObject,ManagementService service){
  super(managedObject,service);
  objectName=createObjectName("String_Node_Str",managedObject.getName());
}

Fixed version (ground truth):
protected MultiMapMBean(MultiMap managedObject,ManagementService service){
  super(managedObject,service);
  objectName=service.createObjectName("String_Node_Str",managedObject.getName());
}
Program: 49121
Project: 49121
Buggy source:
protected QueueMBean(IQueue managedObject,ManagementService service){
  super(managedObject,service);
  objectName=createObjectName("String_Node_Str",managedObject.getName());
  ItemListener itemListener=new ItemListener(){
    public void itemAdded(    ItemEvent item){
      totalAddedItemCount.incrementAndGet();
    }
    public void itemRemoved(    ItemEvent item){
      totalRemovedItemCount.incrementAndGet();
    }
  }
;
  registrationId=managedObject.addItemListener(itemListener,false);
}

Fixed version (ground truth):
protected QueueMBean(IQueue managedObject,ManagementService service){
  super(managedObject,service);
  objectName=service.createObjectName("String_Node_Str",managedObject.getName());
  ItemListener itemListener=new ItemListener(){
    public void itemAdded(    ItemEvent item){
      totalAddedItemCount.incrementAndGet();
    }
    public void itemRemoved(    ItemEvent item){
      totalRemovedItemCount.incrementAndGet();
    }
  }
;
  registrationId=managedObject.addItemListener(itemListener,false);
}
Program: 49122
Project: 49122
Buggy source:
protected SemaphoreMBean(ISemaphore managedObject,ManagementService service){
  super(managedObject,service);
  objectName=createObjectName("String_Node_Str",managedObject.getName());
}

Fixed version (ground truth):
protected SemaphoreMBean(ISemaphore managedObject,ManagementService service){
  super(managedObject,service);
  objectName=service.createObjectName("String_Node_Str",managedObject.getName());
}
Program: 49123
Project: 49123
Buggy source:
public void preDeregister() throws Exception {
  super.preDeregister();
}

Fixed version (ground truth):
public void preDeregister() throws Exception {
  super.preDeregister();
  managedObject.removeItemListener(registrationId);
}
Program: 49124
Project: 49124
Buggy source:
protected SetMBean(ISet managedObject,ManagementService service){
  super(managedObject,service);
  objectName=createObjectName("String_Node_Str",managedObject.getName());
  ItemListener itemListener=new ItemListener(){
    public void itemAdded(    ItemEvent item){
      totalAddedItemCount.incrementAndGet();
    }
    public void itemRemoved(    ItemEvent item){
      totalRemovedItemCount.incrementAndGet();
    }
  }
;
}

Fixed version (ground truth):
protected SetMBean(ISet managedObject,ManagementService service){
  super(managedObject,service);
  objectName=service.createObjectName("String_Node_Str",managedObject.getName());
  ItemListener itemListener=new ItemListener(){
    public void itemAdded(    ItemEvent item){
      totalAddedItemCount.incrementAndGet();
    }
    public void itemRemoved(    ItemEvent item){
      totalRemovedItemCount.incrementAndGet();
    }
  }
;
  registrationId=managedObject.addItemListener(itemListener,false);
}
Program: 49125
Project: 49125
Buggy source:
protected TopicMBean(ITopic managedObject,ManagementService service){
  super(managedObject,service);
  objectName=createObjectName("String_Node_Str",managedObject.getName());
  MessageListener messageListener=new MessageListener(){
    public void onMessage(    Message message){
      totalMessageCount.incrementAndGet();
    }
  }
;
  registrationId=managedObject.addMessageListener(messageListener);
}

Fixed version (ground truth):
protected TopicMBean(ITopic managedObject,ManagementService service){
  super(managedObject,service);
  objectName=service.createObjectName("String_Node_Str",managedObject.getName());
  MessageListener messageListener=new MessageListener(){
    public void onMessage(    Message message){
      totalMessageCount.incrementAndGet();
    }
  }
;
  registrationId=managedObject.addMessageListener(messageListener);
}
Program: 49126
Project: 49126
Buggy source:
void clear(){
  for (  PartitionRecordStore store : maps.values()) {
    store.clear();
  }
  maps.clear();
}

Fixed version (ground truth):
void clear(){
  for (  PartitionRecordStore recordStore : maps.values()) {
    recordStore.clear();
  }
  maps.clear();
}
Program: 49127
Project: 49127
Buggy source:
public void removeAll(){
  final Collection<Data> locks=lockStore != null ? lockStore.getLockedKeys() : Collections.<Data>emptySet();
  final Map<Data,Record> lockRecords=new HashMap<Data,Record>(locks.size());
  for (  Data key : locks) {
    Record record=records.get(key);
    if (record != null) {
      lockRecords.put(key,record);
    }
  }
  Set<Data> keysToDelete=records.keySet();
  keysToDelete.removeAll(lockRecords.keySet());
  final MapStoreWrapper store=mapContainer.getStore();
  if (store != null) {
    Set<Object> keysObject=new HashSet<Object>();
    for (    Data key : keysToDelete) {
      removeIndex(key);
      keysObject.add(mapService.toObject(key));
    }
    store.deleteAll(keysObject);
    toBeRemovedKeys.clear();
  }
  records.clear();
  records.putAll(lockRecords);
}

Fixed version (ground truth):
public void removeAll(){
  final Collection<Data> locks=lockStore != null ? lockStore.getLockedKeys() : Collections.<Data>emptySet();
  final Map<Data,Record> lockRecords=new HashMap<Data,Record>(locks.size());
  for (  Data key : locks) {
    Record record=records.get(key);
    if (record != null) {
      lockRecords.put(key,record);
    }
  }
  Set<Data> keysToDelete=records.keySet();
  keysToDelete.removeAll(lockRecords.keySet());
  final MapStoreWrapper store=mapContainer.getStore();
  Set<Object> keysObject=new HashSet<Object>();
  for (  Data key : keysToDelete) {
    removeIndex(key);
    keysObject.add(mapService.toObject(key));
  }
  if (store != null) {
    store.deleteAll(keysObject);
    toBeRemovedKeys.clear();
  }
  records.clear();
  records.putAll(lockRecords);
}
Program: 49128
Project: 49128
Buggy source:
void clear(){
  final LockService lockService=mapService.getNodeEngine().getSharedService(LockService.SERVICE_NAME);
  if (lockService != null) {
    lockService.clearLockStore(partitionContainer.getPartitionId(),new DefaultObjectNamespace(MapService.SERVICE_NAME,name));
  }
  records.clear();
}

Fixed version (ground truth):
void clear(){
  final LockService lockService=mapService.getNodeEngine().getSharedService(LockService.SERVICE_NAME);
  if (lockService != null) {
    lockService.clearLockStore(partitionContainer.getPartitionId(),new DefaultObjectNamespace(MapService.SERVICE_NAME,name));
  }
  records.clear();
  final IndexService indexService=mapContainer.getIndexService();
  if (indexService.hasIndex()) {
    indexService.clear();
  }
}
Program: 49129
Project: 49129
Buggy source:
public Portable[] readPortableArray(String fieldName) throws IOException {
  FieldDefinition fd=cd.get(fieldName);
  if (fd == null) {
    throw throwUnknownFieldException(fieldName);
  }
  final int currentPos=in.position();
  try {
    int pos=getPosition(fd);
    in.position(pos);
    final int len=in.readInt();
    final Portable[] portables=new Portable[len];
    if (len > 0) {
      final int offset=in.position();
      final PortableContextAwareInputStream ctxIn=(PortableContextAwareInputStream)in;
      try {
        ctxIn.setFactoryId(fd.getFactoryId());
        ctxIn.setClassId(fd.getClassId());
        for (int i=0; i < len; i++) {
          final int start=in.readInt(offset + i * 4);
          in.position(start);
          portables[i]=serializer.read(in);
        }
      }
  finally {
        ctxIn.setFactoryId(cd.getFactoryId());
        ctxIn.setClassId(cd.getClassId());
      }
    }
    return portables;
  }
  finally {
    in.position(currentPos);
  }
}

Fixed version (ground truth):
public Portable[] readPortableArray(String fieldName) throws IOException {
  FieldDefinition fd=cd.get(fieldName);
  if (fd == null) {
    throw throwUnknownFieldException(fieldName);
  }
  final int currentPos=in.position();
  try {
    int pos=getPosition(fd);
    in.position(pos);
    final int len=in.readInt();
    final Portable[] portables=new Portable[len];
    if (len > 0) {
      final int offset=in.position();
      final PortableContextAwareInputStream ctxIn=(PortableContextAwareInputStream)in;
      try {
        ctxIn.setFactoryId(fd.getFactoryId());
        ctxIn.setClassId(fd.getClassId());
        for (int i=0; i < len; i++) {
          final int start=in.readInt(offset + i * 4);
          in.position(start);
          portables[i]=serializer.readAndInitialize(in);
        }
      }
  finally {
        ctxIn.setFactoryId(cd.getFactoryId());
        ctxIn.setClassId(cd.getClassId());
      }
    }
    return portables;
  }
  finally {
    in.position(currentPos);
  }
}
Program: 49130
Project: 49130
Buggy source:
public Portable readPortable(String fieldName) throws IOException {
  FieldDefinition fd=cd.get(fieldName);
  if (fd == null) {
    throw throwUnknownFieldException(fieldName);
  }
  final int currentPos=in.position();
  try {
    int pos=getPosition(fd);
    in.position(pos);
    final boolean NULL=in.readBoolean();
    if (!NULL) {
      final PortableContextAwareInputStream ctxIn=(PortableContextAwareInputStream)in;
      try {
        ctxIn.setFactoryId(fd.getFactoryId());
        ctxIn.setClassId(fd.getClassId());
        return serializer.read(in);
      }
  finally {
        ctxIn.setFactoryId(cd.getFactoryId());
        ctxIn.setClassId(cd.getClassId());
      }
    }
    return null;
  }
  finally {
    in.position(currentPos);
  }
}

Fixed version (ground truth):
public Portable readPortable(String fieldName) throws IOException {
  FieldDefinition fd=cd.get(fieldName);
  if (fd == null) {
    throw throwUnknownFieldException(fieldName);
  }
  final int currentPos=in.position();
  try {
    int pos=getPosition(fd);
    in.position(pos);
    final boolean NULL=in.readBoolean();
    if (!NULL) {
      final PortableContextAwareInputStream ctxIn=(PortableContextAwareInputStream)in;
      try {
        ctxIn.setFactoryId(fd.getFactoryId());
        ctxIn.setClassId(fd.getClassId());
        return serializer.readAndInitialize(in);
      }
  finally {
        ctxIn.setFactoryId(cd.getFactoryId());
        ctxIn.setClassId(cd.getClassId());
      }
    }
    return null;
  }
  finally {
    in.position(currentPos);
  }
}
Program: 49131
Project: 49131
Buggy source:
public int getVersion(){
  return version;
}

Fixed version (ground truth):
public final int getVersion(){
  return version;
}
Program: 49132
Project: 49132
Buggy source:
public int getClassId(){
  return classId;
}

Fixed version (ground truth):
public final int getClassId(){
  return classId;
}
Program: 49133
Project: 49133
Buggy source:
public byte[] getBinary(){
  return binary;
}

Fixed version (ground truth):
public final byte[] getBinary(){
  return binary;
}
Program: 49134
Project: 49134
Buggy source:
public int getFactoryId(){
  return factoryId;
}

Fixed version (ground truth):
public final int getFactoryId(){
  return factoryId;
}
Program: 49135
Project: 49135
Buggy source:
public BinaryClassDefinitionProxy(int factoryId,int classId,int version,byte[] binary){
  this.classId=classId;
  this.version=version;
  this.binary=binary;
  this.factoryId=factoryId;
}

Fixed version (ground truth):
public BinaryClassDefinitionProxy(int factoryId,int classId,int version,byte[] binary){
  this.classId=classId;
  this.version=version;
  this.factoryId=factoryId;
  setBinary(binary);
}
Program: 49136
Project: 49136
Buggy source:
public ClassDefinition toReal(SerializationContext context) throws IOException {
  final ClassDefinition cd=context.lookup(factoryId,classId,version);
  return cd != null ? cd : context.createClassDefinition(factoryId,binary);
}

Fixed version (ground truth):
public ClassDefinition toReal(SerializationContext context) throws IOException {
  final ClassDefinition cd=context.lookup(factoryId,classId,version);
  return cd != null ? cd : context.createClassDefinition(factoryId,getBinary());
}
Program: 49137
Project: 49137
Buggy source:
@Override public String toString(){
  final StringBuilder sb=new StringBuilder();
  sb.append("String_Node_Str");
  sb.append("String_Node_Str").append(classId);
  sb.append("String_Node_Str").append(version);
  sb.append("String_Node_Str").append(fieldDefinitions);
  sb.append('}');
  return sb.toString();
}

Fixed version (ground truth):
@Override public String toString(){
  final StringBuilder sb=new StringBuilder();
  sb.append("String_Node_Str");
  sb.append("String_Node_Str").append(factoryId);
  sb.append("String_Node_Str").append(classId);
  sb.append("String_Node_Str").append(version);
  sb.append("String_Node_Str").append(fieldDefinitions);
  sb.append('}');
  return sb.toString();
}
Program: 49138
Project: 49138
Buggy source:
ClassDefinition registerClassDefinition(ClassDefinition cd){
  if (cd == null)   return null;
  final ClassDefinitionImpl cdImpl=(ClassDefinitionImpl)cd;
  if (cdImpl.getVersion() < 0) {
    cdImpl.version=getVersion();
  }
  final long versionedClassId=combineToLong(cdImpl.getClassId(),cdImpl.getVersion());
  final ClassDefinitionImpl currentClassDef=versionedDefinitions.putIfAbsent(versionedClassId,cdImpl);
  if (currentClassDef == null) {
    registerNestedDefinitions(cdImpl);
    if (cdImpl.getBinary() == null) {
      final BufferObjectDataOutput out=serializationService.pop();
      try {
        cdImpl.writeData(out);
        final byte[] binary=out.toByteArray();
        out.clear();
        compress(binary,out);
        cdImpl.setBinary(out.toByteArray());
      }
 catch (      IOException e) {
        throw new HazelcastSerializationException(e);
      }
 finally {
        serializationService.push(out);
      }
    }
    return cd;
  }
  return currentClassDef;
}

Fixed version (ground truth):
ClassDefinition registerClassDefinition(ClassDefinition cd){
  if (cd == null)   return null;
  final ClassDefinitionImpl cdImpl=(ClassDefinitionImpl)cd;
  if (cdImpl.getVersion() < 0) {
    cdImpl.version=getVersion();
  }
  if (cdImpl.getBinary() == null) {
    final BufferObjectDataOutput out=serializationService.pop();
    try {
      cdImpl.writeData(out);
      final byte[] binary=out.toByteArray();
      out.clear();
      compress(binary,out);
      cdImpl.setBinary(out.toByteArray());
    }
 catch (    IOException e) {
      throw new HazelcastSerializationException(e);
    }
 finally {
      serializationService.push(out);
    }
  }
  final long versionedClassId=combineToLong(cdImpl.getClassId(),cdImpl.getVersion());
  final ClassDefinitionImpl currentClassDef=versionedDefinitions.putIfAbsent(versionedClassId,cdImpl);
  if (currentClassDef == null) {
    registerNestedDefinitions(cdImpl);
    return cd;
  }
  return currentClassDef;
}
Program: 49139
Project: 49139
Buggy source:
static void compress(byte[] input,DataOutput out) throws IOException {
  Deflater deflater=new Deflater();
  deflater.setLevel(Deflater.BEST_COMPRESSION);
  deflater.setInput(input);
  deflater.finish();
  byte[] buf=new byte[input.length / 10];
  while (!deflater.finished()) {
    int count=deflater.deflate(buf);
    out.write(buf,0,count);
  }
  deflater.end();
}

Fixed version (ground truth):
static void compress(byte[] input,DataOutput out) throws IOException {
  Deflater deflater=new Deflater();
  deflater.setLevel(Deflater.DEFAULT_COMPRESSION);
  deflater.setStrategy(Deflater.FILTERED);
  deflater.setInput(input);
  deflater.finish();
  byte[] buf=new byte[1024];
  while (!deflater.finished()) {
    int count=deflater.deflate(buf);
    out.write(buf,0,count);
  }
  deflater.end();
}
Program: 49140
Project: 49140
Buggy source:
ClassDefinition createClassDefinition(byte[] compressedBinary) throws IOException {
  final BufferObjectDataOutput out=serializationService.pop();
  final byte[] binary;
  try {
    decompress(compressedBinary,out);
    binary=out.toByteArray();
  }
  finally {
    serializationService.push(out);
  }
  final ClassDefinitionImpl cd=new ClassDefinitionImpl();
  cd.readData(serializationService.createObjectDataInput(binary));
  cd.setBinary(compressedBinary);
  final ClassDefinitionImpl currentCD=versionedDefinitions.putIfAbsent(combineToLong(cd.classId,getVersion()),cd);
  if (currentCD == null) {
    registerNestedDefinitions(cd);
    return cd;
  }
 else {
    return currentCD;
  }
}

Fixed version (ground truth):
ClassDefinition createClassDefinition(byte[] compressedBinary) throws IOException {
  if (compressedBinary == null || compressedBinary.length == 0) {
    throw new IOException("String_Node_Str");
  }
  final BufferObjectDataOutput out=serializationService.pop();
  final byte[] binary;
  try {
    decompress(compressedBinary,out);
    binary=out.toByteArray();
  }
  finally {
    serializationService.push(out);
  }
  final ClassDefinitionImpl cd=new ClassDefinitionImpl();
  cd.readData(serializationService.createObjectDataInput(binary));
  cd.setBinary(compressedBinary);
  final ClassDefinitionImpl currentCD=versionedDefinitions.putIfAbsent(combineToLong(cd.classId,getVersion()),cd);
  if (currentCD == null) {
    registerNestedDefinitions(cd);
    return cd;
  }
 else {
    return currentCD;
  }
}
Program: 49141
Project: 49141
Buggy source:
public MultiMapTransactionLog(Data key,CollectionProxyId proxyId,long ttl,int threadId,long version,Operation op){
  this.key=key;
  this.proxyId=proxyId;
  this.ttl=ttl;
  this.threadId=threadId;
  this.txVersion=version;
  opList.add(op);
}

Fixed version (ground truth):
public MultiMapTransactionLog(Data key,CollectionProxyId proxyId,long ttl,int threadId,long version){
  this.key=key;
  this.proxyId=proxyId;
  this.ttl=ttl;
  this.threadId=threadId;
  this.txVersion=version;
}
Program: 49142
Project: 49142
Buggy source:
protected Collection<CollectionRecord> removeAllInternal(Data key){
  throwExceptionIfNull(key);
  long timeout=tx.getTimeoutMillis();
  long ttl=timeout * 3 / 2;
  Collection<CollectionRecord> coll=txMap.get(key);
  if (coll == null) {
    CollectionResponse response=lockAndGet(key,timeout,ttl);
    if (response == null) {
      throw new ConcurrentModificationException("String_Node_Str" + getThreadId());
    }
    version=response.getTxVersion();
    coll=createCollection(response.getRecordCollection(getNodeEngine()));
  }
  txMap.put(key,createCollection());
  TxnRemoveAllOperation operation=new TxnRemoveAllOperation(proxyId,key,coll);
  MultiMapTransactionLog log=(MultiMapTransactionLog)tx.getTransactionLog(getTxLogKey(key));
  if (log != null) {
    log.addOperation(operation);
  }
 else {
    log=new MultiMapTransactionLog(key,proxyId,ttl,getThreadId(),version,operation);
    tx.addTransactionLog(log);
  }
  return coll;
}

Fixed version (ground truth):
protected Collection<CollectionRecord> removeAllInternal(Data key){
  throwExceptionIfNull(key);
  long timeout=tx.getTimeoutMillis();
  long ttl=timeout * 3 / 2;
  Collection<CollectionRecord> coll=txMap.get(key);
  final MultiMapTransactionLog log;
  if (coll == null) {
    CollectionResponse response=lockAndGet(key,timeout,ttl);
    if (response == null) {
      throw new ConcurrentModificationException("String_Node_Str" + getThreadId());
    }
    log=new MultiMapTransactionLog(key,proxyId,ttl,getThreadId(),version);
    version=response.getTxVersion();
    coll=createCollection(response.getRecordCollection(getNodeEngine()));
  }
 else {
    log=(MultiMapTransactionLog)tx.getTransactionLog(getTxLogKey(key));
  }
  txMap.put(key,createCollection());
  TxnRemoveAllOperation operation=new TxnRemoveAllOperation(proxyId,key,coll);
  log.addOperation(operation);
  return coll;
}
Program: 49143
Project: 49143
Buggy source:
protected boolean putInternal(Data key,Data value){
  throwExceptionIfNull(key);
  throwExceptionIfNull(value);
  Collection<CollectionRecord> coll=txMap.get(key);
  long recordId=-1;
  long timeout=tx.getTimeoutMillis();
  long ttl=timeout * 3 / 2;
  if (coll == null) {
    CollectionResponse response=lockAndGet(key,timeout,ttl);
    if (response == null) {
      throw new ConcurrentModificationException("String_Node_Str" + getThreadId());
    }
    recordId=response.getNextRecordId();
    version=response.getTxVersion();
    coll=createCollection(response.getRecordCollection(getNodeEngine()));
    txMap.put(key,coll);
  }
  CollectionRecord record=new CollectionRecord(config.isBinary() ? value : getNodeEngine().toObject(value));
  if (coll.add(record)) {
    if (recordId == -1) {
      recordId=nextId(key);
    }
    record.setRecordId(recordId);
    TxnPutOperation operation=new TxnPutOperation(proxyId,key,value,recordId);
    MultiMapTransactionLog log=(MultiMapTransactionLog)tx.getTransactionLog(getTxLogKey(key));
    if (log != null) {
      log.addOperation(operation);
    }
 else {
      log=new MultiMapTransactionLog(key,proxyId,ttl,getThreadId(),version,operation);
      tx.addTransactionLog(log);
    }
    return true;
  }
  return false;
}

Fixed version (ground truth):
protected boolean putInternal(Data key,Data value){
  throwExceptionIfNull(key);
  throwExceptionIfNull(value);
  Collection<CollectionRecord> coll=txMap.get(key);
  long recordId=-1;
  long timeout=tx.getTimeoutMillis();
  long ttl=timeout * 3 / 2;
  final MultiMapTransactionLog log;
  if (coll == null) {
    CollectionResponse response=lockAndGet(key,timeout,ttl);
    if (response == null) {
      throw new ConcurrentModificationException("String_Node_Str" + getThreadId());
    }
    log=new MultiMapTransactionLog(key,proxyId,ttl,getThreadId(),version);
    tx.addTransactionLog(log);
    recordId=response.getNextRecordId();
    version=response.getTxVersion();
    coll=createCollection(response.getRecordCollection(getNodeEngine()));
    txMap.put(key,coll);
  }
 else {
    log=(MultiMapTransactionLog)tx.getTransactionLog(getTxLogKey(key));
  }
  CollectionRecord record=new CollectionRecord(config.isBinary() ? value : getNodeEngine().toObject(value));
  if (coll.add(record)) {
    if (recordId == -1) {
      recordId=nextId(key);
    }
    record.setRecordId(recordId);
    TxnPutOperation operation=new TxnPutOperation(proxyId,key,value,recordId);
    log.addOperation(operation);
    return true;
  }
  return false;
}
Program: 49144
Project: 49144
Buggy source:
protected boolean removeInternal(Data key,Data value){
  throwExceptionIfNull(key);
  throwExceptionIfNull(value);
  Collection<CollectionRecord> coll=txMap.get(key);
  long timeout=tx.getTimeoutMillis();
  long ttl=timeout * 3 / 2;
  if (coll == null) {
    CollectionResponse response=lockAndGet(key,timeout,ttl);
    if (response == null) {
      throw new ConcurrentModificationException("String_Node_Str" + getThreadId());
    }
    version=response.getTxVersion();
    coll=createCollection(response.getRecordCollection(getNodeEngine()));
    txMap.put(key,coll);
  }
  CollectionRecord record=new CollectionRecord(config.isBinary() ? value : getNodeEngine().toObject(value));
  Iterator<CollectionRecord> iterator=coll.iterator();
  long recordId=-1;
  while (iterator.hasNext()) {
    CollectionRecord r=iterator.next();
    if (r.equals(record)) {
      iterator.remove();
      recordId=r.getRecordId();
      break;
    }
  }
  if (version != -1 || recordId != -1) {
    TxnRemoveOperation operation=new TxnRemoveOperation(proxyId,key,recordId,value);
    MultiMapTransactionLog log=(MultiMapTransactionLog)tx.getTransactionLog(getTxLogKey(key));
    if (log != null) {
      log.addOperation(operation);
    }
 else {
      log=new MultiMapTransactionLog(key,proxyId,ttl,getThreadId(),version,operation);
      tx.addTransactionLog(log);
    }
    return recordId != -1;
  }
  return false;
}

Fixed version (ground truth):
protected boolean removeInternal(Data key,Data value){
  throwExceptionIfNull(key);
  throwExceptionIfNull(value);
  Collection<CollectionRecord> coll=txMap.get(key);
  long timeout=tx.getTimeoutMillis();
  long ttl=timeout * 3 / 2;
  final MultiMapTransactionLog log;
  if (coll == null) {
    CollectionResponse response=lockAndGet(key,timeout,ttl);
    if (response == null) {
      throw new ConcurrentModificationException("String_Node_Str" + getThreadId());
    }
    log=new MultiMapTransactionLog(key,proxyId,ttl,getThreadId(),version);
    tx.addTransactionLog(log);
    version=response.getTxVersion();
    coll=createCollection(response.getRecordCollection(getNodeEngine()));
    txMap.put(key,coll);
  }
 else {
    log=(MultiMapTransactionLog)tx.getTransactionLog(getTxLogKey(key));
  }
  CollectionRecord record=new CollectionRecord(config.isBinary() ? value : getNodeEngine().toObject(value));
  Iterator<CollectionRecord> iterator=coll.iterator();
  long recordId=-1;
  while (iterator.hasNext()) {
    CollectionRecord r=iterator.next();
    if (r.equals(record)) {
      iterator.remove();
      recordId=r.getRecordId();
      break;
    }
  }
  if (version != -1 || recordId != -1) {
    TxnRemoveOperation operation=new TxnRemoveOperation(proxyId,key,recordId,value);
    log.addOperation(operation);
    return recordId != -1;
  }
  return false;
}
Program: 49145
Project: 49145
Buggy source:
@Override public String toString(){
  return "String_Node_Str" + endpoint + "String_Node_Str"+ socket.getInetAddress().getHostAddress()+ "String_Node_Str"+ socket.getPort()+ "String_Node_Str";
}

Fixed version (ground truth):
@Override public String toString(){
  return "String_Node_Str" + endpoint + "String_Node_Str"+ socket.getLocalSocketAddress()+ "String_Node_Str";
}
Program: 49146
Project: 49146
Buggy source:
public Connection getConnection(Address address) throws IOException {
  checkLive();
  if (address == null) {
    throw new IllegalArgumentException("String_Node_Str");
  }
  final ObjectPool<ConnectionWrapper> pool=getConnectionPool(address);
  if (pool == null) {
    return null;
  }
  Connection connection=null;
  try {
    connection=pool.take();
  }
 catch (  Exception e) {
    logger.log(Level.WARNING,"String_Node_Str",e);
  }
  if (connection != null && !heartbeat.checkHeartBeat(connection)) {
    connection.close();
    connection=null;
  }
  return connection;
}

Fixed version (ground truth):
public Connection getConnection(Address address) throws IOException {
  checkLive();
  if (address == null) {
    throw new IllegalArgumentException("String_Node_Str");
  }
  final ObjectPool<ConnectionWrapper> pool=getConnectionPool(address);
  if (pool == null) {
    return null;
  }
  Connection connection=null;
  try {
    connection=pool.take();
  }
 catch (  Exception e) {
    logger.log(Level.WARNING,"String_Node_Str" + address,e);
  }
  if (connection != null && !heartbeat.checkHeartBeat(connection)) {
    logger.log(Level.WARNING,connection + "String_Node_Str");
    connection.close();
    connection=null;
  }
  return connection;
}
Program: 49147
Project: 49147
Buggy source:
public void close(){
  IOUtil.closeResource(connection);
}

Fixed version (ground truth):
public void close(){
  logger.log(Level.INFO,"String_Node_Str" + connection);
  IOUtil.closeResource(connection);
}
Program: 49148
Project: 49148
Buggy source:
private <T>T sendAndReceive(Connection conn,Object obj) throws IOException {
  try {
    final SerializationService serializationService=getSerializationService();
    final Data request=serializationService.toData(obj);
    conn.write(request);
    final Data response=conn.read();
    final Object result=serializationService.toObject(response);
    return ErrorHandler.returnResultOrThrowException(result);
  }
 catch (  Exception e) {
    return retryOrThrowException(obj,null,e);
  }
}

Fixed version (ground truth):
<T>T sendAndReceive(final Address address,Object obj) throws IOException {
  return _sendAndReceive(new TargetConnectionFactory(address),obj);
}
Program: 49149
Project: 49149
Buggy source:
private void beforeRetry(){
  try {
    Thread.sleep(RETRY_WAIT_TIME);
  }
 catch (  InterruptedException ignored) {
  }
}

Fixed version (ground truth):
private void beforeRetry(){
  try {
    Thread.sleep(RETRY_WAIT_TIME);
    ((ClientPartitionServiceImpl)client.getClientPartitionService()).refreshPartitions();
  }
 catch (  InterruptedException ignored) {
  }
}
Program: 49150
Project: 49150
Buggy source:
private void sendAndHandle(Connection conn,Object obj,ResponseHandler handler) throws IOException {
  ResponseStream stream=null;
  try {
    final SerializationService serializationService=getSerializationService();
    final Data request=serializationService.toData(obj);
    conn.write(request);
    stream=new ResponseStreamImpl(serializationService,conn);
  }
 catch (  Exception e) {
    retryOrThrowException(obj,handler,e);
  }
  if (stream != null) {
    try {
      handler.handle(stream);
    }
 catch (    Exception e) {
      throw ExceptionUtil.rethrow(e,IOException.class);
    }
 finally {
      stream.end();
    }
  }
}

Fixed version (ground truth):
void sendAndHandle(Object obj,ResponseHandler handler) throws IOException {
  _sendAndHandle(randomConnectionFactory,obj,handler);
}
Program: 49151
Project: 49151
Buggy source:
private void loadInitialMemberList() throws IOException {
  SerializableCollection coll=sendAndReceive(conn,new AddMembershipListenerRequest());
  final SerializationService serializationService=getSerializationService();
  Map<String,MemberImpl> prevMembers=Collections.emptyMap();
  if (!members.isEmpty()) {
    prevMembers=new HashMap<String,MemberImpl>(members.size());
    for (    MemberImpl member : members) {
      prevMembers.put(member.getUuid(),member);
    }
    members.clear();
  }
  for (  Data d : coll.getCollection()) {
    members.add((MemberImpl)serializationService.toObject(d));
  }
  updateMembersRef();
  logger.log(Level.INFO,membersString());
  final List<MembershipEvent> events=new LinkedList<MembershipEvent>();
  for (  MemberImpl member : members) {
    final MemberImpl former=prevMembers.remove(member.getUuid());
    if (former == null) {
      events.add(new MembershipEvent(member,MembershipEvent.MEMBER_ADDED));
    }
  }
  for (  MemberImpl member : prevMembers.values()) {
    events.add(new MembershipEvent(member,MembershipEvent.MEMBER_REMOVED));
  }
  for (  MembershipEvent event : events) {
    fireMembershipEvent(event);
  }
}

Fixed version (ground truth):
private void loadInitialMemberList() throws IOException {
  final SerializationService serializationService=getSerializationService();
  final Data request=serializationService.toData(new AddMembershipListenerRequest());
  conn.write(request);
  final Data response=conn.read();
  SerializableCollection coll=ErrorHandler.returnResultOrThrowException(serializationService.toObject(response));
  Map<String,MemberImpl> prevMembers=Collections.emptyMap();
  if (!members.isEmpty()) {
    prevMembers=new HashMap<String,MemberImpl>(members.size());
    for (    MemberImpl member : members) {
      prevMembers.put(member.getUuid(),member);
    }
    members.clear();
  }
  for (  Data d : coll.getCollection()) {
    members.add((MemberImpl)serializationService.toObject(d));
  }
  updateMembersRef();
  logger.log(Level.INFO,membersString());
  final List<MembershipEvent> events=new LinkedList<MembershipEvent>();
  for (  MemberImpl member : members) {
    final MemberImpl former=prevMembers.remove(member.getUuid());
    if (former == null) {
      events.add(new MembershipEvent(member,MembershipEvent.MEMBER_ADDED));
    }
  }
  for (  MemberImpl member : prevMembers.values()) {
    events.add(new MembershipEvent(member,MembershipEvent.MEMBER_REMOVED));
  }
  for (  MembershipEvent event : events) {
    fireMembershipEvent(event);
  }
}
Program: 49152
Project: 49152
Buggy source:
private void processPartitionResponse(PartitionsResponse response){
  final Address[] members=response.getMembers();
  final int[] ownerIndexes=response.getOwnerIndexes();
  if (partitionCount == 0) {
    partitions=new ConcurrentHashMap<Integer,Address>(271,0.75f,1);
    partitionCount=ownerIndexes.length;
  }
  for (int partitionId=0; partitionId < partitionCount; partitionId++) {
    final int ownerIndex=ownerIndexes[partitionId];
    if (ownerIndex > -1) {
      partitions.put(partitionId,members[ownerIndex]);
    }
  }
}

Fixed version (ground truth):
private void processPartitionResponse(PartitionsResponse response){
  final Address[] members=response.getMembers();
  final int[] ownerIndexes=response.getOwnerIndexes();
  if (partitionCount == 0) {
    partitionCount=ownerIndexes.length;
  }
  for (int partitionId=0; partitionId < partitionCount; partitionId++) {
    final int ownerIndex=ownerIndexes[partitionId];
    if (ownerIndex > -1) {
      partitions.put(partitionId,members[ownerIndex]);
    }
  }
}
Program: 49153
Project: 49153
Buggy source:
public void start(){
  getInitialPartitions();
  client.getClientExecutionService().scheduleWithFixedDelay(new Runnable(){
    public void run(){
      final ClientClusterService clusterService=client.getClientClusterService();
      final Address master=clusterService.getMasterAddress();
      final PartitionsResponse response=getPartitionsFrom((ClientClusterServiceImpl)clusterService,master);
      if (response != null) {
        processPartitionResponse(response);
      }
    }
  }
,10,10,TimeUnit.SECONDS);
}

Fixed version (ground truth):
public void start(){
  getInitialPartitions();
  client.getClientExecutionService().scheduleWithFixedDelay(new RefreshTask(),10,10,TimeUnit.SECONDS);
}
Program: 49154
Project: 49154
Buggy source:
public void run(){
  final ClientClusterService clusterService=client.getClientClusterService();
  final Address master=clusterService.getMasterAddress();
  final PartitionsResponse response=getPartitionsFrom((ClientClusterServiceImpl)clusterService,master);
  if (response != null) {
    processPartitionResponse(response);
  }
}

Fixed version (ground truth):
public void run(){
  if (updating.compareAndSet(false,true)) {
    try {
      final ClientClusterService clusterService=client.getClientClusterService();
      final Address master=clusterService.getMasterAddress();
      final PartitionsResponse response=getPartitionsFrom((ClientClusterServiceImpl)clusterService,master);
      if (response != null) {
        processPartitionResponse(response);
      }
    }
  finally {
      updating.set(false);
    }
  }
}
Program: 49155
Project: 49155
Buggy source:
@Test public void testOperationRedo() throws Exception {
  final HazelcastInstance hz1=Hazelcast.newHazelcastInstance();
  final HazelcastInstance hz2=Hazelcast.newHazelcastInstance();
  ClientConfig clientConfig=new ClientConfig();
  clientConfig.setRedoOperation(true);
  HazelcastInstance client=HazelcastClient.newHazelcastClient(clientConfig);
  final Thread thread=new Thread(){
    public void run(){
      try {
        Thread.sleep(100);
      }
 catch (      InterruptedException e) {
        e.printStackTrace();
      }
      hz1.getLifecycleService().terminate();
    }
  }
;
  final IQueue<Object> q=client.getQueue("String_Node_Str");
  thread.start();
  for (int i=0; i < 1000; i++) {
    q.offer("String_Node_Str" + i);
  }
  thread.join();
  assertEquals(1000,q.size());
}

Fixed version (ground truth):
@Test public void testOperationRedo() throws Exception {
  final HazelcastInstance hz1=Hazelcast.newHazelcastInstance();
  final HazelcastInstance hz2=Hazelcast.newHazelcastInstance();
  ClientConfig clientConfig=new ClientConfig();
  clientConfig.setRedoOperation(true);
  HazelcastInstance client=HazelcastClient.newHazelcastClient(clientConfig);
  final Thread thread=new Thread(){
    public void run(){
      try {
        Thread.sleep(100);
      }
 catch (      InterruptedException e) {
        e.printStackTrace();
      }
      hz1.getLifecycleService().terminate();
    }
  }
;
  final IMap map=client.getMap("String_Node_Str");
  thread.start();
  int expected=1000;
  for (int i=0; i < expected; i++) {
    map.put(i,"String_Node_Str" + i);
  }
  thread.join();
  assertEquals(expected,map.size());
}
Program: 49157
Project: 49157
Buggy source:
/** 
 * Testing if topic can properly listen messages and if topic has any issue after a shutdown.
 */
@Test public void testTopicCluster(){
  final Config cfg=new Config();
  TestHazelcastInstanceFactory factory=createHazelcastInstanceFactory(2);
  HazelcastInstance[] instances=factory.newInstances(cfg);
  HazelcastInstance h1=instances[0];
  HazelcastInstance h2=instances[1];
  String topicName="String_Node_Str";
  ITopic<String> topic1=h1.getTopic(topicName);
  final CountDownLatch latch1=new CountDownLatch(1);
  topic1.addMessageListener(new MessageListener<String>(){
    public void onMessage(    Message msg){
      assertEquals("String_Node_Str",msg.getMessageObject());
      latch1.countDown();
    }
  }
);
  ITopic<String> topic2=h2.getTopic(topicName);
  final CountDownLatch latch2=new CountDownLatch(2);
  topic2.addMessageListener(new MessageListener<String>(){
    public void onMessage(    Message msg){
      assertEquals("String_Node_Str",msg.getMessageObject());
      latch2.countDown();
    }
  }
);
  topic1.publish("String_Node_Str");
  h1.getLifecycleService().shutdown();
  topic2.publish("String_Node_Str");
  try {
    assertTrue(latch1.await(5,TimeUnit.SECONDS));
    assertTrue(latch2.await(5,TimeUnit.SECONDS));
  }
 catch (  InterruptedException ignored) {
  }
}

Fixed version (ground truth):
/** 
 * Testing if topic can properly listen messages and if topic has any issue after a shutdown.
 */
@Test public void testTopicCluster() throws InterruptedException {
  final Config cfg=new Config();
  TestHazelcastInstanceFactory factory=createHazelcastInstanceFactory(2);
  HazelcastInstance[] instances=factory.newInstances(cfg);
  HazelcastInstance h1=instances[0];
  HazelcastInstance h2=instances[1];
  String topicName="String_Node_Str";
  ITopic<String> topic1=h1.getTopic(topicName);
  final CountDownLatch latch1=new CountDownLatch(1);
  final String message="String_Node_Str";
  topic1.addMessageListener(new MessageListener<String>(){
    public void onMessage(    Message msg){
      assertEquals(message,msg.getMessageObject());
      latch1.countDown();
    }
  }
);
  ITopic<String> topic2=h2.getTopic(topicName);
  final CountDownLatch latch2=new CountDownLatch(2);
  topic2.addMessageListener(new MessageListener<String>(){
    public void onMessage(    Message msg){
      assertEquals(message,msg.getMessageObject());
      latch2.countDown();
    }
  }
);
  topic1.publish(message);
  assertTrue(latch1.await(5,TimeUnit.SECONDS));
  h1.getLifecycleService().shutdown();
  topic2.publish(message);
  assertTrue(latch2.await(5,TimeUnit.SECONDS));
}
Program: 49158
Project: 49158
Buggy source:
@Test public void testMapEvictAndListener() throws InterruptedException {
  IMap<String,String> map=getInstance().getMap("String_Node_Str");
  final String value1="String_Node_Str";
  final String value2="String_Node_Str";
  final List<String> newList=new CopyOnWriteArrayList<String>();
  final CountDownLatch latch1=new CountDownLatch(1);
  final CountDownLatch latch2=new CountDownLatch(1);
  map.addEntryListener(new EntryAdapter<String,String>(){
    public void entryEvicted(    EntryEvent<String,String> event){
      if (value1.equals(event.getValue())) {
        latch1.countDown();
      }
 else       if (value2.equals(event.getValue())) {
        latch2.countDown();
      }
      newList.add(event.getValue());
    }
  }
,true);
  map.put("String_Node_Str",value1,1,TimeUnit.SECONDS);
  assertTrue(latch1.await(10,TimeUnit.SECONDS));
  map.put("String_Node_Str",value2,1,TimeUnit.SECONDS);
  assertTrue(latch2.await(10,TimeUnit.SECONDS));
  assertEquals(value1,newList.get(0));
  assertEquals(value2,newList.get(1));
}

Fixed version (ground truth):
@Test public void testMapEvictAndListener() throws InterruptedException {
  IMap<String,String> map=getInstance().getMap("String_Node_Str");
  final String value1="String_Node_Str";
  final String value2="String_Node_Str";
  final List<String> newList=new CopyOnWriteArrayList<String>();
  final CountDownLatch latch1=new CountDownLatch(1);
  final CountDownLatch latch2=new CountDownLatch(1);
  map.addEntryListener(new EntryAdapter<String,String>(){
    public void entryEvicted(    EntryEvent<String,String> event){
      if (value1.equals(event.getValue())) {
        newList.add(event.getValue());
        latch1.countDown();
      }
 else       if (value2.equals(event.getValue())) {
        newList.add(event.getValue());
        latch2.countDown();
      }
    }
  }
,true);
  map.put("String_Node_Str",value1,1,TimeUnit.SECONDS);
  assertTrue(latch1.await(10,TimeUnit.SECONDS));
  map.put("String_Node_Str",value2,1,TimeUnit.SECONDS);
  assertTrue(latch2.await(10,TimeUnit.SECONDS));
  assertEquals(value1,newList.get(0));
  assertEquals(value2,newList.get(1));
}
Program: 49159
Project: 49159
Buggy source:
public void run(){
  int ttl=(int)(Math.random() * 5000 + 3000);
  for (int j=0; j < putCount; j++) {
    final long expectedEvictionTime=ttl + System.currentTimeMillis();
    map.put(j + putCount * threadId,expectedEvictionTime,ttl,TimeUnit.MILLISECONDS);
  }
}

Fixed version (ground truth):
public void run(){
  while (!Thread.currentThread().isInterrupted()) {
    try {
      for (int i=0; i < nsize; i++) {
        map.get(i);
      }
      Thread.sleep(1000);
    }
 catch (    HazelcastInstanceNotActiveException e) {
      return;
    }
catch (    InterruptedException e) {
      return;
    }
  }
}