nus-yam/ex-repair huggingface dataset:
Program: 47655
Project: 47655
Buggy source:
@Override public void run(){
  waitForPacketsProcessed();
  cleanResources(new TargetDisconnectedException(remoteEndpoint));
}

Fixed version (ground truth):
@Override public void run(){
  waitForPacketsProcessed();
  cleanResources(new ConstructorFunction<Object,Throwable>(){
    @Override public Throwable createNew(    Object arg){
      return new TargetDisconnectedException(remoteEndpoint);
    }
  }
);
}
Program: 47656
Project: 47656
Buggy source:
private void innerClose() throws IOException {
  if (!live) {
    return;
  }
  live=false;
  if (socketChannelWrapper.isOpen()) {
    socketChannelWrapper.close();
  }
  readHandler.shutdown();
  writeHandler.shutdown();
  if (socketChannelWrapper.isBlocking()) {
    return;
  }
  if (connectionManager.isAlive()) {
    try {
      executionService.execute(new CleanResourcesTask());
    }
 catch (    RejectedExecutionException e) {
      logger.warning("String_Node_Str",e);
    }
  }
 else {
    cleanResources(new HazelcastException("String_Node_Str"));
  }
}

Fixed version (ground truth):
private void innerClose() throws IOException {
  if (!live) {
    return;
  }
  live=false;
  if (socketChannelWrapper.isOpen()) {
    socketChannelWrapper.close();
  }
  readHandler.shutdown();
  writeHandler.shutdown();
  if (socketChannelWrapper.isBlocking()) {
    return;
  }
  if (connectionManager.isAlive()) {
    try {
      executionService.execute(new CleanResourcesTask());
    }
 catch (    RejectedExecutionException e) {
      logger.warning("String_Node_Str",e);
    }
  }
 else {
    cleanResources(new ConstructorFunction<Object,Throwable>(){
      @Override public Throwable createNew(      Object arg){
        return new HazelcastException("String_Node_Str");
      }
    }
);
  }
}
Program: 47657
Project: 47657
Buggy source:
private void cleanResources(HazelcastException response){
  final Iterator<Map.Entry<Integer,ClientCallFuture>> iter=callIdMap.entrySet().iterator();
  while (iter.hasNext()) {
    final Map.Entry<Integer,ClientCallFuture> entry=iter.next();
    iter.remove();
    entry.getValue().notify(response);
    eventHandlerMap.remove(entry.getKey());
  }
  final Iterator<ClientCallFuture> iterator=eventHandlerMap.values().iterator();
  while (iterator.hasNext()) {
    final ClientCallFuture future=iterator.next();
    iterator.remove();
    future.notify(response);
  }
}

Fixed version (ground truth):
private void cleanResources(ConstructorFunction<Object,Throwable> responseCtor){
  final Iterator<Map.Entry<Integer,ClientCallFuture>> iter=callIdMap.entrySet().iterator();
  while (iter.hasNext()) {
    final Map.Entry<Integer,ClientCallFuture> entry=iter.next();
    iter.remove();
    entry.getValue().notify(responseCtor.createNew(null));
    eventHandlerMap.remove(entry.getKey());
  }
  final Iterator<ClientCallFuture> iterator=eventHandlerMap.values().iterator();
  while (iterator.hasNext()) {
    final ClientCallFuture future=iterator.next();
    iterator.remove();
    future.notify(responseCtor.createNew(null));
  }
}
Program: 47658
Project: 47658
Buggy source:
@Override public void shutdown(){
  shutdown=true;
  logger.finest("String_Node_Str");
  final Object response=new HazelcastInstanceNotActiveException();
  for (  BasicInvocation invocation : invocations.values()) {
    try {
      invocation.notify(response);
    }
 catch (    Throwable e) {
      logger.warning(invocation + "String_Node_Str" + e.getMessage());
    }
  }
  invocations.clear();
  scheduler.shutdown();
}

Fixed version (ground truth):
@Override public void shutdown(){
  shutdown=true;
  logger.finest("String_Node_Str");
  for (  BasicInvocation invocation : invocations.values()) {
    try {
      invocation.notify(new HazelcastInstanceNotActiveException());
    }
 catch (    Throwable e) {
      logger.warning(invocation + "String_Node_Str" + e.getMessage());
    }
  }
  invocations.clear();
  scheduler.shutdown();
}
Program: 47659
Project: 47659
Buggy source:
private void updateLocalEntry(ReplicatedRecord<K,V> localEntry,ReplicationMessage update){
  final VectorClockTimestamp currentVectorClockTimestamp=localEntry.getVectorClockTimestamp();
  final VectorClockTimestamp updateVectorClockTimestamp=update.getVectorClockTimestamp();
  if (isOldTombstone(localEntry)) {
    applyTheUpdate(update,localEntry);
  }
 else   if (VectorClockTimestamp.happenedBefore(currentVectorClockTimestamp,updateVectorClockTimestamp)) {
    applyTheUpdate(update,localEntry);
  }
 else   if (VectorClockTimestamp.happenedBefore(updateVectorClockTimestamp,currentVectorClockTimestamp)) {
    return;
  }
 else   if (!updateVectorClockTimestamp.equals(currentVectorClockTimestamp)) {
    if (localEntry.getLatestUpdateHash() >= update.getUpdateHash()) {
      applyTheUpdate(update,localEntry);
    }
 else {
      VectorClockTimestamp newTimestamp=localEntry.applyAndIncrementVectorClock(updateVectorClockTimestamp,localMember);
      Object key=update.getKey();
      V value=localEntry.getValue();
      long ttlMillis=update.getTtlMillis();
      int latestUpdateHash=localEntry.getLatestUpdateHash();
      ReplicationMessage message=new ReplicationMessage(name,key,value,newTimestamp,localMember,latestUpdateHash,ttlMillis);
      distributeReplicationMessage(message,true);
    }
  }
 else {
    LOGGER.finest("String_Node_Str" + "String_Node_Str");
  }
}

Fixed version (ground truth):
private void updateLocalEntry(ReplicatedRecord<K,V> localEntry,ReplicationMessage update){
  final VectorClockTimestamp currentVectorClockTimestamp=localEntry.getVectorClockTimestamp();
  final VectorClockTimestamp updateVectorClockTimestamp=update.getVectorClockTimestamp();
  if (isOldTombstone(localEntry)) {
    applyTheUpdate(update,localEntry);
  }
 else   if (VectorClockTimestamp.happenedBefore(currentVectorClockTimestamp,updateVectorClockTimestamp)) {
    applyTheUpdate(update,localEntry);
  }
 else   if (VectorClockTimestamp.happenedBefore(updateVectorClockTimestamp,currentVectorClockTimestamp)) {
    return;
  }
 else   if (!updateVectorClockTimestamp.equals(currentVectorClockTimestamp)) {
    if (localEntry.getLatestUpdateHash() >= update.getUpdateHash()) {
      applyTheUpdate(update,localEntry);
    }
 else {
      VectorClockTimestamp newTimestamp=localEntry.applyAndIncrementVectorClock(updateVectorClockTimestamp,localMember);
      Object key=update.getKey();
      V v=localEntry.getValue();
      V value=v instanceof Data ? (V)nodeEngine.toObject(v) : v;
      long ttlMillis=update.getTtlMillis();
      int latestUpdateHash=localEntry.getLatestUpdateHash();
      ReplicationMessage message=new ReplicationMessage(name,key,value,newTimestamp,localMember,latestUpdateHash,ttlMillis);
      distributeReplicationMessage(message,true);
    }
  }
 else {
    LOGGER.finest("String_Node_Str" + "String_Node_Str");
  }
}
Program: 47660
Project: 47660
Buggy source:
private void updateLocalEntry(ReplicatedRecord<K,V> localEntry,ReplicationMessage update){
  final VectorClockTimestamp currentVectorClockTimestamp=localEntry.getVectorClockTimestamp();
  final VectorClockTimestamp updateVectorClockTimestamp=update.getVectorClockTimestamp();
  if (isOldTombstone(localEntry)) {
    applyTheUpdate(update,localEntry);
  }
 else   if (VectorClockTimestamp.happenedBefore(currentVectorClockTimestamp,updateVectorClockTimestamp)) {
    applyTheUpdate(update,localEntry);
  }
 else   if (VectorClockTimestamp.happenedBefore(updateVectorClockTimestamp,currentVectorClockTimestamp)) {
    return;
  }
 else   if (!updateVectorClockTimestamp.equals(currentVectorClockTimestamp)) {
    if (localEntry.getLatestUpdateHash() >= update.getUpdateHash()) {
      applyTheUpdate(update,localEntry);
    }
 else {
      VectorClockTimestamp newTimestamp=localEntry.applyAndIncrementVectorClock(updateVectorClockTimestamp,localMember);
      Object key=update.getKey();
      V value=localEntry.getValue();
      long ttlMillis=update.getTtlMillis();
      int latestUpdateHash=localEntry.getLatestUpdateHash();
      ReplicationMessage message=new ReplicationMessage(name,key,value,newTimestamp,localMember,latestUpdateHash,ttlMillis);
      distributeReplicationMessage(message,true);
    }
  }
 else {
    LOGGER.finest("String_Node_Str" + "String_Node_Str");
  }
}

Fixed version (ground truth):
private void updateLocalEntry(ReplicatedRecord<K,V> localEntry,ReplicationMessage update){
  final VectorClockTimestamp currentVectorClockTimestamp=localEntry.getVectorClockTimestamp();
  final VectorClockTimestamp updateVectorClockTimestamp=update.getVectorClockTimestamp();
  if (isOldTombstone(localEntry)) {
    applyTheUpdate(update,localEntry);
  }
 else   if (VectorClockTimestamp.happenedBefore(currentVectorClockTimestamp,updateVectorClockTimestamp)) {
    applyTheUpdate(update,localEntry);
  }
 else   if (VectorClockTimestamp.happenedBefore(updateVectorClockTimestamp,currentVectorClockTimestamp)) {
    return;
  }
 else   if (!updateVectorClockTimestamp.equals(currentVectorClockTimestamp)) {
    if (localEntry.getLatestUpdateHash() >= update.getUpdateHash()) {
      applyTheUpdate(update,localEntry);
    }
 else {
      VectorClockTimestamp newTimestamp=localEntry.applyAndIncrementVectorClock(updateVectorClockTimestamp,localMember);
      Object key=update.getKey();
      V v=localEntry.getValue();
      V value=v instanceof Data ? (V)nodeEngine.toObject(v) : v;
      long ttlMillis=update.getTtlMillis();
      int latestUpdateHash=localEntry.getLatestUpdateHash();
      ReplicationMessage message=new ReplicationMessage(name,key,value,newTimestamp,localMember,latestUpdateHash,ttlMillis);
      distributeReplicationMessage(message,true);
    }
  }
 else {
    LOGGER.finest("String_Node_Str" + "String_Node_Str");
  }
}
Program: 47661
Project: 47661
Buggy source:
public Map<String,String> getAddresses() throws Exception {
  return new DescribeInstances(awsConfig).execute(endpoint);
}

Fixed version (ground truth):
public Map<String,String> getAddresses() throws Exception {
  return new DescribeInstances(awsConfig).execute();
}
Program: 47662
Project: 47662
Buggy source:
public Collection<String> getPrivateIpAddresses() throws Exception {
  final Map<String,String> result=new DescribeInstances(awsConfig).execute(endpoint);
  return result.keySet();
}

Fixed version (ground truth):
public Collection<String> getPrivateIpAddresses() throws Exception {
  final Map<String,String> result=new DescribeInstances(awsConfig).execute();
  return result.keySet();
}
Program: 47663
Project: 47663
Buggy source:
@Override public void incrementAccessHit(){
  accessHit++;
}

Fixed version (ground truth):
@Override @edu.umd.cs.findbugs.annotations.SuppressWarnings(value="String_Node_Str",justification="String_Node_Str") public void incrementAccessHit(){
  accessHit++;
}
Program: 47664
Project: 47664
Buggy source:
@Override protected void handleSelectionKey(SelectionKey sk){
  if (sk.isValid() && sk.isReadable()) {
    readKeyCount++;
    SelectionHandler handler=(SelectionHandler)sk.attachment();
    handler.handle();
  }
}

Fixed version (ground truth):
@Override @edu.umd.cs.findbugs.annotations.SuppressWarnings({"String_Node_Str"}) protected void handleSelectionKey(SelectionKey sk){
  if (sk.isValid() && sk.isReadable()) {
    readEvents++;
    SelectionHandler handler=(SelectionHandler)sk.attachment();
    handler.handle();
  }
}
Program: 47665
Project: 47665
Buggy source:
@Override protected void handleSelectionKey(SelectionKey sk){
  if (sk.isValid() && sk.isWritable()) {
    writeKeyCount++;
    sk.interestOps(sk.interestOps() & ~SelectionKey.OP_WRITE);
    SelectionHandler handler=(SelectionHandler)sk.attachment();
    handler.handle();
  }
}

Fixed version (ground truth):
@Override @edu.umd.cs.findbugs.annotations.SuppressWarnings({"String_Node_Str"}) protected void handleSelectionKey(SelectionKey sk){
  if (sk.isValid() && sk.isWritable()) {
    writeEvents++;
    sk.interestOps(sk.interestOps() & ~SelectionKey.OP_WRITE);
    SelectionHandler handler=(SelectionHandler)sk.attachment();
    handler.handle();
  }
}
Program: 47666
Project: 47666
Buggy source:
@Override public void dumpPerformanceMetrics(StringBuffer sb){
  for (int k=0; k < inSelectors.length; k++) {
    sb.append("String_Node_Str").append(k).append("String_Node_Str").append(inSelectors[k].getReadKeyCount()).append("String_Node_Str");
  }
  for (int k=0; k < outSelectors.length; k++) {
    sb.append("String_Node_Str").append(k).append("String_Node_Str").append(outSelectors[k].getWriteKeyCount()).append("String_Node_Str");
  }
}

Fixed version (ground truth):
@Override public void dumpPerformanceMetrics(StringBuffer sb){
  for (int k=0; k < inSelectors.length; k++) {
    InSelectorImpl inSelector=inSelectors[k];
    sb.append(inSelector.getName()).append("String_Node_Str").append(inSelector.getReadEvents()).append("String_Node_Str");
  }
  for (int k=0; k < outSelectors.length; k++) {
    OutSelectorImpl outSelector=outSelectors[k];
    sb.append(outSelector.getName()).append("String_Node_Str").append(outSelector.getWriteEvents()).append("String_Node_Str");
  }
}
Program: 47667
Project: 47667
Buggy source:
public TcpIpConnectionManager(IOService ioService,ServerSocketChannel serverSocketChannel){
  this.ioService=ioService;
  this.serverSocketChannel=serverSocketChannel;
  this.logger=ioService.getLogger(TcpIpConnectionManager.class.getName());
  this.socketReceiveBufferSize=ioService.getSocketReceiveBufferSize() * IOService.KILO_BYTE;
  this.socketSendBufferSize=ioService.getSocketSendBufferSize() * IOService.KILO_BYTE;
  this.socketLingerSeconds=ioService.getSocketLingerSeconds();
  this.socketKeepAlive=ioService.getSocketKeepAlive();
  this.socketNoDelay=ioService.getSocketNoDelay();
  this.selectorThreadCount=ioService.getSelectorThreadCount();
  this.inSelectors=new InSelectorImpl[selectorThreadCount];
  this.outSelectors=new OutSelectorImpl[selectorThreadCount];
  final Collection<Integer> ports=ioService.getOutboundPorts();
  this.outboundPortCount=ports == null ? 0 : ports.size();
  if (ports != null) {
    outboundPorts.addAll(ports);
  }
  this.socketChannelWrapperFactory=ioService.getSocketChannelWrapperFactory();
  this.portableContext=ioService.getPortableContext();
  this.selectorImbalancWorkaroundEnabled=parseBoolean(System.getProperty("String_Node_Str","String_Node_Str"));
  if (selectorImbalancWorkaroundEnabled) {
    selectorIndexPerHostMap=new ConcurrentHashMap<String,Integer>();
    logger.severe("String_Node_Str" + "String_Node_Str" + "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str");
  }
 else {
    selectorIndexPerHostMap=null;
  }
}

Fixed version (ground truth):
public TcpIpConnectionManager(IOService ioService,ServerSocketChannel serverSocketChannel){
  this.ioService=ioService;
  this.serverSocketChannel=serverSocketChannel;
  this.logger=ioService.getLogger(TcpIpConnectionManager.class.getName());
  this.socketReceiveBufferSize=ioService.getSocketReceiveBufferSize() * IOService.KILO_BYTE;
  this.socketSendBufferSize=ioService.getSocketSendBufferSize() * IOService.KILO_BYTE;
  this.socketLingerSeconds=ioService.getSocketLingerSeconds();
  this.socketKeepAlive=ioService.getSocketKeepAlive();
  this.socketNoDelay=ioService.getSocketNoDelay();
  this.selectorThreadCount=ioService.getSelectorThreadCount();
  this.inSelectors=new InSelectorImpl[selectorThreadCount];
  this.outSelectors=new OutSelectorImpl[selectorThreadCount];
  final Collection<Integer> ports=ioService.getOutboundPorts();
  this.outboundPortCount=ports == null ? 0 : ports.size();
  if (ports != null) {
    outboundPorts.addAll(ports);
  }
  this.socketChannelWrapperFactory=ioService.getSocketChannelWrapperFactory();
  this.portableContext=ioService.getPortableContext();
  this.selectorImbalancWorkaroundEnabled=isSelectorImbalanceEnabled();
  this.selectorIndexPerHostMap=selectorImbalancWorkaroundEnabled ? new HashMap<String,Integer>() : null;
}
Program: 47668
Project: 47668
Buggy source:
TcpIpConnection assignSocketChannel(SocketChannelWrapper channel,Address endpoint){
  InetSocketAddress remoteSocketAddress=(InetSocketAddress)channel.socket().getRemoteSocketAddress();
  String remoteHost=remoteSocketAddress.getHostName();
  Integer index;
  if (selectorImbalancWorkaroundEnabled) {
synchronized (selectorIndexPerHostMap) {
      index=selectorIndexPerHostMap.get(remoteHost);
      if (index == null) {
        index=nextSelectorIndex();
        selectorIndexPerHostMap.put(remoteHost,index);
        logger.info(remoteHost + "String_Node_Str" + index);
      }
 else {
        logger.info(remoteHost + "String_Node_Str" + index);
      }
    }
  }
 else {
    index=nextSelectorIndex();
  }
  final TcpIpConnection connection=new TcpIpConnection(this,inSelectors[index],outSelectors[index],connectionIdGen.incrementAndGet(),channel);
  connection.setEndPoint(endpoint);
  activeConnections.add(connection);
  acceptedSockets.remove(channel);
  connection.getReadHandler().register();
  if (selectorImbalancWorkaroundEnabled) {
    log(Level.INFO,"String_Node_Str" + channel.socket().getLocalSocketAddress() + "String_Node_Str"+ remoteSocketAddress+ "String_Node_Str"+ index+ "String_Node_Str"+ activeConnections.size());
  }
 else {
    log(Level.INFO,"String_Node_Str" + channel.socket().getLocalSocketAddress() + "String_Node_Str"+ remoteSocketAddress);
  }
  return connection;
}

Fixed version (ground truth):
TcpIpConnection assignSocketChannel(SocketChannelWrapper channel,Address endpoint){
  InetSocketAddress remoteSocketAddress=(InetSocketAddress)channel.socket().getRemoteSocketAddress();
  String remoteHost=remoteSocketAddress.getHostName();
  int index=getSelectorIndex(remoteHost);
  final TcpIpConnection connection=new TcpIpConnection(this,inSelectors[index],outSelectors[index],connectionIdGen.incrementAndGet(),channel);
  connection.setEndPoint(endpoint);
  activeConnections.add(connection);
  acceptedSockets.remove(channel);
  connection.getReadHandler().register();
  logConnectionEstablished(channel,remoteSocketAddress,index);
  return connection;
}
Program: 47669
Project: 47669
Buggy source:
/** 
 * Adds all kinds of performance metrics. It is up to the implementation to add anything.
 */
void dumpPerformanceMetrics(StringBuffer sb);

Fixed version (ground truth):
/** 
 * Dumps all kinds of performance metrics. It is up to the implementation to add anything.
 */
void dumpPerformanceMetrics(StringBuffer sb);
Program: 47670
Project: 47670
Buggy source:
/** 
 * Returns all kinds of metrics, e.g. performance. This can be used for performance analysis. In the future we'll have a more formal (e.g map with key/value pairs) information.
 * @return the metrics in String form. If the implementation doesn't support metrics, null is returned.
 */
void dumpPerformanceMetrics(StringBuffer sb);

Fixed version (ground truth):
/** 
 * Dumps all kinds of metrics, e.g. performance. This can be used for performance analysis. In the future we'll have a more formal (e.g map with key/value pairs) information.
 */
void dumpPerformanceMetrics(StringBuffer sb);
Program: 47671
Project: 47671
Buggy source:
@Before public void init(){
  Config config=new Config();
  config.getNetworkConfig().getJoin().getMulticastConfig().setEnabled(false);
  config.getNetworkConfig().setPort(5701);
  config.getGroupConfig().setName("String_Node_Str");
  config.getGroupConfig().setPassword("String_Node_Str");
  final HazelcastInstance hz1=Hazelcast.newHazelcastInstance(config);
  Config config2=new Config();
  config2.getNetworkConfig().getJoin().getMulticastConfig().setEnabled(false);
  config2.getNetworkConfig().setPort(5702);
  config2.getGroupConfig().setName("String_Node_Str");
  config2.getGroupConfig().setPassword("String_Node_Str");
  final HazelcastInstance hz2=Hazelcast.newHazelcastInstance(config2);
}

Fixed version (ground truth):
@Before public void init(){
  Config config=new Config();
  config.getNetworkConfig().getJoin().getMulticastConfig().setEnabled(false);
  config.getNetworkConfig().setPort(5701);
  config.getGroupConfig().setName("String_Node_Str");
  config.getGroupConfig().setPassword("String_Node_Str");
  config.addCacheConfig(simpleConfig);
  Hazelcast.newHazelcastInstance(config);
  Config config2=new Config();
  config2.getNetworkConfig().getJoin().getMulticastConfig().setEnabled(false);
  config2.getNetworkConfig().setPort(5702);
  config2.getGroupConfig().setName("String_Node_Str");
  config2.getGroupConfig().setPassword("String_Node_Str");
  config.addCacheConfig(simpleConfig);
  Hazelcast.newHazelcastInstance(config2);
}
Program: 47672
Project: 47672
Buggy source:
@After public void tearDown(){
  Hazelcast.shutdownAll();
}

Fixed version (ground truth):
@After public void tearDown(){
  HazelcastClient.shutdownAll();
  HazelcastInstanceFactory.terminateAll();
}
Program: 47673
Project: 47673
Buggy source:
protected <K,V>ICache<?,?> getCacheUnchecked(String cacheName){
  final String cacheNameWithPrefix=getCacheNameWithPrefix(cacheName);
  ICache<?,?> cache=caches.get(cacheNameWithPrefix);
  if (cache == null) {
    CacheConfig<K,V> cacheConfig=null;
    if (cacheConfig == null) {
      cacheConfig=getCacheConfigFromPartition(cacheNameWithPrefix,cacheName);
    }
    if (cacheConfig == null) {
      return null;
    }
    final ICache<K,V> cacheProxy=createCacheProxy(cacheConfig);
    final ICache<?,?> iCache=caches.putIfAbsent(cacheNameWithPrefix,cacheProxy);
    cache=iCache != null ? iCache : cacheProxy;
  }
  return cache;
}

Fixed version (ground truth):
protected <K,V>ICache<?,?> getCacheUnchecked(String cacheName){
  final String cacheNameWithPrefix=getCacheNameWithPrefix(cacheName);
  ICache<?,?> cache=caches.get(cacheNameWithPrefix);
  if (cache == null) {
    CacheConfig<K,V> cacheConfig=getCacheConfigFromPartition(cacheNameWithPrefix,cacheName);
    if (cacheConfig == null) {
      return null;
    }
    final ICache<K,V> cacheProxy=createCacheProxy(cacheConfig);
    final ICache<?,?> iCache=caches.putIfAbsent(cacheNameWithPrefix,cacheProxy);
    cache=iCache != null ? iCache : cacheProxy;
  }
  return cache;
}
Program: 47674
Project: 47674
Buggy source:
@Override public void run() throws Exception {
  final CacheService service=getService();
  final CacheConfig cacheConfig=service.getCacheConfig(name);
  if (cacheConfig == null) {
    CacheSimpleConfig simpleConfig=service.findCacheConfig(simpleName);
    if (simpleConfig != null) {
      try {
        CacheConfig cacheConfigFromSimpleConfig=new CacheConfig(simpleConfig);
        cacheConfigFromSimpleConfig.setName(name);
        cacheConfigFromSimpleConfig.setManagerPrefix(name.substring(0,name.lastIndexOf(simpleName)));
        if (service.createCacheConfigIfAbsent(cacheConfigFromSimpleConfig,false) == null) {
          response=cacheConfigFromSimpleConfig;
          return;
        }
      }
 catch (      Exception e) {
        throw new CacheException(e);
      }
    }
  }
  response=cacheConfig;
}

Fixed version (ground truth):
@Override public void run() throws Exception {
  final CacheService service=getService();
  final CacheConfig cacheConfig=service.getCacheConfig(name);
  if (cacheConfig == null) {
    CacheSimpleConfig simpleConfig=service.findCacheConfig(simpleName);
    if (simpleConfig != null) {
      try {
        CacheConfig cacheConfigFromSimpleConfig=new CacheConfig(simpleConfig);
        cacheConfigFromSimpleConfig.setName(simpleName);
        cacheConfigFromSimpleConfig.setManagerPrefix(name.substring(0,name.lastIndexOf(simpleName)));
        if (service.createCacheConfigIfAbsent(cacheConfigFromSimpleConfig,false) == null) {
          response=cacheConfigFromSimpleConfig;
          return;
        }
      }
 catch (      Exception e) {
        throw new CacheException(e);
      }
    }
  }
  response=cacheConfig;
}
Program: 47675
Project: 47675
Buggy source:
@Test public void defaultCacheTest(){
  CacheManager cacheManager=Caching.getCachingProvider().getCacheManager();
  assertNotNull(cacheManager);
  Cache testCache=cacheManager.getCache("String_Node_Str");
  assertNull(testCache);
  Caching.getCachingProvider().close();
}

Fixed version (ground truth):
@Test public void defaultCacheTest(){
  CacheManager cacheManager=Caching.getCachingProvider().getCacheManager();
  assertNotNull(cacheManager);
  Cache testCache=cacheManager.getCache("String_Node_Str");
  assertNull(testCache);
}
Program: 47676
Project: 47676
Buggy source:
@Test public void cacheManagerByLocationFileTest() throws URISyntaxException {
  URI uri=new URI("String_Node_Str");
  String urlStr=configUrl1.toString();
  assertEquals("String_Node_Str",urlStr.substring(0,4));
  Properties properties=new Properties();
  properties.setProperty(HazelcastCachingProvider.HAZELCAST_CONFIG_LOCATION,urlStr);
  CacheManager cacheManager=Caching.getCachingProvider().getCacheManager(uri,null,properties);
  assertNotNull(cacheManager);
  URI uri2=new URI("String_Node_Str");
  String urlStr2=configUrl2.toString();
  assertEquals("String_Node_Str",urlStr2.substring(0,4));
  Properties properties2=new Properties();
  properties2.setProperty(HazelcastCachingProvider.HAZELCAST_CONFIG_LOCATION,urlStr2);
  CacheManager cacheManager2=Caching.getCachingProvider().getCacheManager(uri2,null,properties2);
  assertNotNull(cacheManager2);
  assertEquals(2,Hazelcast.getAllHazelcastInstances().size());
  Caching.getCachingProvider().close();
}

Fixed version (ground truth):
@Test public void cacheManagerByLocationFileTest() throws URISyntaxException {
  URI uri=new URI("String_Node_Str");
  String urlStr=configUrl1.toString();
  assertEquals("String_Node_Str",urlStr.substring(0,4));
  Properties properties=new Properties();
  properties.setProperty(HazelcastCachingProvider.HAZELCAST_CONFIG_LOCATION,urlStr);
  CacheManager cacheManager=Caching.getCachingProvider().getCacheManager(uri,null,properties);
  assertNotNull(cacheManager);
  URI uri2=new URI("String_Node_Str");
  String urlStr2=configUrl2.toString();
  assertEquals("String_Node_Str",urlStr2.substring(0,4));
  Properties properties2=new Properties();
  properties2.setProperty(HazelcastCachingProvider.HAZELCAST_CONFIG_LOCATION,urlStr2);
  CacheManager cacheManager2=Caching.getCachingProvider().getCacheManager(uri2,null,properties2);
  assertNotNull(cacheManager2);
  assertEquals(2,Hazelcast.getAllHazelcastInstances().size());
}
Program: 47677
Project: 47677
Buggy source:
@Test public void cacheManagerByInstanceNameTest() throws URISyntaxException {
  final String instanceName="String_Node_Str";
  Config config=new Config();
  config.setInstanceName(instanceName);
  Hazelcast.newHazelcastInstance(config);
  URI uri1=new URI("String_Node_Str");
  Properties properties=new Properties();
  properties.setProperty(HazelcastCachingProvider.HAZELCAST_INSTANCE_NAME,instanceName);
  CacheManager cacheManager=Caching.getCachingProvider().getCacheManager(uri1,null,properties);
  assertNotNull(cacheManager);
  assertEquals(1,Hazelcast.getAllHazelcastInstances().size());
  Caching.getCachingProvider().close();
  Hazelcast.getHazelcastInstanceByName(instanceName).shutdown();
}

Fixed version (ground truth):
@Test public void cacheManagerByInstanceNameTest() throws URISyntaxException {
  final String instanceName="String_Node_Str";
  Config config=new Config();
  config.setInstanceName(instanceName);
  Hazelcast.newHazelcastInstance(config);
  URI uri1=new URI("String_Node_Str");
  Properties properties=new Properties();
  properties.setProperty(HazelcastCachingProvider.HAZELCAST_INSTANCE_NAME,instanceName);
  CacheManager cacheManager=Caching.getCachingProvider().getCacheManager(uri1,null,properties);
  assertNotNull(cacheManager);
  assertEquals(1,Hazelcast.getAllHazelcastInstances().size());
}
Program: 47678
Project: 47678
Buggy source:
@Test public void cacheManagerByLocationClasspathTest() throws URISyntaxException {
  URI uri1=new URI("String_Node_Str");
  Properties properties=new Properties();
  properties.setProperty(HazelcastCachingProvider.HAZELCAST_CONFIG_LOCATION,"String_Node_Str");
  CacheManager cacheManager=Caching.getCachingProvider().getCacheManager(uri1,null,properties);
  assertNotNull(cacheManager);
  Cache<Integer,String> testCache=cacheManager.getCache("String_Node_Str",Integer.class,String.class);
  assertNotNull(testCache);
  Caching.getCachingProvider().close();
}

Fixed version (ground truth):
@Test public void cacheManagerByLocationClasspathTest() throws URISyntaxException {
  URI uri1=new URI("String_Node_Str");
  Properties properties=new Properties();
  properties.setProperty(HazelcastCachingProvider.HAZELCAST_CONFIG_LOCATION,"String_Node_Str");
  CacheManager cacheManager=Caching.getCachingProvider().getCacheManager(uri1,null,properties);
  assertNotNull(cacheManager);
  Cache<Integer,String> testCache=cacheManager.getCache("String_Node_Str",Integer.class,String.class);
  assertNotNull(testCache);
}
Program: 47679
Project: 47679
Buggy source:
public void addInterceptor(String id,MapInterceptor interceptor){
  interceptorMap.put(id,interceptor);
  interceptors.add(interceptor);
}

Fixed version (ground truth):
public void addInterceptor(String id,MapInterceptor interceptor){
  removeInterceptor(id);
  interceptorMap.put(id,interceptor);
  interceptors.add(interceptor);
}
Program: 47680
Project: 47680
Buggy source:
public void addInterceptor(String id,MapInterceptor interceptor){
  interceptorMap.put(id,interceptor);
  interceptors.add(interceptor);
}

Fixed version (ground truth):
public void addInterceptor(String id,MapInterceptor interceptor){
  removeInterceptor(id);
  interceptorMap.put(id,interceptor);
  interceptors.add(interceptor);
}
Program: 47681
Project: 47681
Buggy source:
/** 
 * Shutdown the provided client and remove it prom the managed list
 * @param instanceName the hazelcast client instance name
 */
public static void shutdown(String instanceName){
  HazelcastClientProxy proxy=CLIENTS.remove(instanceName);
  if (proxy != null) {
    try {
      proxy.client.shutdown();
    }
 catch (    Exception ignored) {
      EmptyStatement.ignore(ignored);
    }
    proxy.client=null;
  }
}

Fixed version (ground truth):
/** 
 * Shutdown the provided client and remove it from the managed list
 * @param instanceName the hazelcast client instance name
 */
public static void shutdown(String instanceName){
  HazelcastClientProxy proxy=CLIENTS.remove(instanceName);
  if (proxy != null) {
    try {
      proxy.client.shutdown();
    }
 catch (    Exception ignored) {
      EmptyStatement.ignore(ignored);
    }
    proxy.client=null;
  }
}
Program: 47682
Project: 47682
Buggy source:
public HazelcastClientCacheManager(HazelcastClientCachingProvider cachingProvider,HazelcastInstance hazelcastInstance,URI uri,ClassLoader classLoader,Properties properties){
  super(cachingProvider,uri,classLoader,properties);
  if (hazelcastInstance == null) {
    throw new NullPointerException("String_Node_Str");
  }
  this.hazelcastInstance=hazelcastInstance;
  final ClientCacheDistributedObject setupRef=hazelcastInstance.getDistributedObject(CacheService.SERVICE_NAME,"String_Node_Str");
  this.clientContext=setupRef.getClientContext();
  logger=Logger.getLogger(getClass());
}

Fixed version (ground truth):
public HazelcastClientCacheManager(HazelcastClientCachingProvider cachingProvider,HazelcastInstance hazelcastInstance,URI uri,ClassLoader classLoader,Properties properties){
  super(cachingProvider,uri,classLoader,properties);
  if (hazelcastInstance == null) {
    throw new NullPointerException("String_Node_Str");
  }
  this.hazelcastInstance=hazelcastInstance;
  final ClientCacheDistributedObject setupRef=hazelcastInstance.getDistributedObject(CacheService.SERVICE_NAME,"String_Node_Str");
  this.clientContext=setupRef.getClientContext();
}
Program: 47683
Project: 47683
Buggy source:
void setPartitionReplicaVersions(int partitionId,long[] versions);

Fixed version (ground truth):
void setPartitionReplicaVersions(int partitionId,long[] versions,int replicaOffset);
Program: 47684
Project: 47684
Buggy source:
/** 
 * Provides a similar functionality as committing a transaction. So, at the end of the process method, applyChanges will be called to apply latest data into   {@link CacheRecordStore}.
 */
public void applyChanges(){
  final boolean isStatisticsEnabled=cacheRecordStore.cacheConfig.isStatisticsEnabled();
  final CacheStatisticsImpl statistics=cacheRecordStore.statistics;
switch (state) {
case ACCESS:
    cacheRecordStore.accessRecord(record,expiryPolicy,now);
  break;
case UPDATE:
cacheRecordStore.updateRecordWithExpiry(keyData,value,record,expiryPolicy,now,false);
if (isStatisticsEnabled) {
statistics.increaseCachePuts(1);
statistics.addGetTimeNano(System.nanoTime() - start);
}
break;
case REMOVE:
cacheRecordStore.remove(keyData,null);
break;
case CREATE:
if (isStatisticsEnabled) {
statistics.increaseCachePuts(1);
statistics.addGetTimeNano(System.nanoTime() - start);
}
cacheRecordStore.createRecordWithExpiry(keyData,value,expiryPolicy,now,false);
break;
case LOAD:
cacheRecordStore.createRecordWithExpiry(keyData,value,expiryPolicy,now,true);
break;
case NONE:
break;
default :
break;
}
}

Fixed version (ground truth):
/** 
 * Provides a similar functionality as committing a transaction. So, at the end of the process method, applyChanges will be called to apply latest data into   {@link CacheRecordStore}.
 */
public void applyChanges(){
  final boolean isStatisticsEnabled=cacheRecordStore.cacheConfig.isStatisticsEnabled();
  final CacheStatisticsImpl statistics=cacheRecordStore.statistics;
switch (state) {
case ACCESS:
    cacheRecordStore.accessRecord(record,expiryPolicy,now);
  break;
case UPDATE:
cacheRecordStore.updateRecordWithExpiry(keyData,value,record,expiryPolicy,now,false);
if (isStatisticsEnabled) {
statistics.increaseCachePuts(1);
statistics.addGetTimeNanos(System.nanoTime() - start);
}
break;
case REMOVE:
cacheRecordStore.remove(keyData,null);
break;
case CREATE:
if (isStatisticsEnabled) {
statistics.increaseCachePuts(1);
statistics.addGetTimeNanos(System.nanoTime() - start);
}
cacheRecordStore.createRecordWithExpiry(keyData,value,expiryPolicy,now,false);
break;
case LOAD:
cacheRecordStore.createRecordWithExpiry(keyData,value,expiryPolicy,now,true);
break;
case NONE:
break;
default :
break;
}
}
Program: 47685
Project: 47685
Buggy source:
@Override public Object invoke(Data key,EntryProcessor entryProcessor,Object[] arguments){
  final long now=Clock.currentTimeMillis();
  final long start=isStatisticsEnabled() ? System.nanoTime() : 0;
  CacheRecord record=records.get(key);
  final boolean isExpired=processExpiredEntry(key,record,now);
  if (isExpired) {
    record=null;
  }
  if (isStatisticsEnabled()) {
    if (record == null || isExpired) {
      statistics.increaseCacheMisses(1);
    }
 else {
      statistics.increaseCacheHits(1);
    }
  }
  if (isStatisticsEnabled()) {
    statistics.addGetTimeNano(System.nanoTime() - start);
  }
  CacheEntryProcessorEntry entry=new CacheEntryProcessorEntry(key,record,this,now);
  final Object process=entryProcessor.process(entry,arguments);
  entry.applyChanges();
  return process;
}

Fixed version (ground truth):
@Override public Object invoke(Data key,EntryProcessor entryProcessor,Object[] arguments){
  final long now=Clock.currentTimeMillis();
  final long start=isStatisticsEnabled() ? System.nanoTime() : 0;
  CacheRecord record=records.get(key);
  final boolean isExpired=processExpiredEntry(key,record,now);
  if (isExpired) {
    record=null;
  }
  if (isStatisticsEnabled()) {
    if (record == null || isExpired) {
      statistics.increaseCacheMisses(1);
    }
 else {
      statistics.increaseCacheHits(1);
    }
  }
  if (isStatisticsEnabled()) {
    statistics.addGetTimeNanos(System.nanoTime() - start);
  }
  CacheEntryProcessorEntry entry=new CacheEntryProcessorEntry(key,record,this,now);
  final Object process=entryProcessor.process(entry,arguments);
  entry.applyChanges();
  return process;
}
Program: 47686
Project: 47686
Buggy source:
private void updateGetAndPutStat(boolean isPutSucceed,boolean getValue,boolean oldValueNull,long start){
  if (isStatisticsEnabled()) {
    if (isPutSucceed) {
      statistics.increaseCachePuts(1);
      statistics.addPutTimeNano(System.nanoTime() - start);
    }
    if (getValue) {
      if (oldValueNull) {
        statistics.increaseCacheMisses(1);
      }
 else {
        statistics.increaseCacheHits(1);
      }
      statistics.addGetTimeNano(System.nanoTime() - start);
    }
  }
}

Fixed version (ground truth):
private void updateGetAndPutStat(boolean isPutSucceed,boolean getValue,boolean oldValueNull,long start){
  if (isStatisticsEnabled()) {
    if (isPutSucceed) {
      statistics.increaseCachePuts(1);
      statistics.addPutTimeNanos(System.nanoTime() - start);
    }
    if (getValue) {
      if (oldValueNull) {
        statistics.increaseCacheMisses(1);
      }
 else {
        statistics.increaseCacheHits(1);
      }
      statistics.addGetTimeNanos(System.nanoTime() - start);
    }
  }
}
Program: 47687
Project: 47687
Buggy source:
private void updateReplaceStat(boolean result,boolean isHit,long start){
  if (isStatisticsEnabled()) {
    if (result) {
      statistics.increaseCachePuts(1);
      statistics.addPutTimeNano(System.nanoTime() - start);
    }
    statistics.addGetTimeNano(System.nanoTime() - start);
    if (isHit) {
      statistics.increaseCacheHits(1);
    }
 else {
      statistics.increaseCacheMisses(1);
    }
  }
}

Fixed version (ground truth):
private void updateReplaceStat(boolean result,boolean isHit,long start){
  if (isStatisticsEnabled()) {
    if (result) {
      statistics.increaseCachePuts(1);
      statistics.addPutTimeNanos(System.nanoTime() - start);
    }
    statistics.addGetTimeNanos(System.nanoTime() - start);
    if (isHit) {
      statistics.increaseCacheHits(1);
    }
 else {
      statistics.increaseCacheMisses(1);
    }
  }
}
Program: 47688
Project: 47688
Buggy source:
@Override public Object getAndReplace(Data key,Object value,ExpiryPolicy expiryPolicy,String caller){
  final ExpiryPolicy localExpiryPolicy=expiryPolicy != null ? expiryPolicy : defaultExpiryPolicy;
  final long now=Clock.currentTimeMillis();
  final long start=isStatisticsEnabled() ? System.nanoTime() : 0;
  Object result=null;
  CacheRecord record=records.get(key);
  boolean isExpired=record != null && record.isExpiredAt(now);
  if (record == null || isExpired) {
    result=null;
  }
 else {
    result=record.getValue();
    updateRecordWithExpiry(key,value,record,localExpiryPolicy,now,false);
  }
  if (isStatisticsEnabled()) {
    statistics.addGetTimeNano(System.nanoTime() - start);
    if (result != null) {
      statistics.increaseCacheHits(1);
      statistics.increaseCachePuts(1);
      statistics.addPutTimeNano(System.nanoTime() - start);
    }
 else {
      statistics.increaseCacheMisses(1);
    }
  }
  return result;
}

Fixed version (ground truth):
@Override public Object getAndReplace(Data key,Object value,ExpiryPolicy expiryPolicy,String caller){
  final ExpiryPolicy localExpiryPolicy=expiryPolicy != null ? expiryPolicy : defaultExpiryPolicy;
  final long now=Clock.currentTimeMillis();
  final long start=isStatisticsEnabled() ? System.nanoTime() : 0;
  Object result=null;
  CacheRecord record=records.get(key);
  boolean isExpired=record != null && record.isExpiredAt(now);
  if (record == null || isExpired) {
    result=null;
  }
 else {
    result=record.getValue();
    updateRecordWithExpiry(key,value,record,localExpiryPolicy,now,false);
  }
  if (isStatisticsEnabled()) {
    statistics.addGetTimeNanos(System.nanoTime() - start);
    if (result != null) {
      statistics.increaseCacheHits(1);
      statistics.increaseCachePuts(1);
      statistics.addPutTimeNanos(System.nanoTime() - start);
    }
 else {
      statistics.increaseCacheMisses(1);
    }
  }
  return result;
}
Program: 47689
Project: 47689
Buggy source:
@Override public Object getAndRemove(Data key,String caller){
  final long now=Clock.currentTimeMillis();
  final long start=isStatisticsEnabled() ? System.nanoTime() : 0;
  deleteCacheEntry(key);
  CacheRecord record=records.get(key);
  boolean isExpired=record != null && record.isExpiredAt(now);
  final Object result;
  if (record == null || isExpired) {
    result=null;
  }
 else {
    result=record.getValue();
    deleteRecord(key);
  }
  if (isStatisticsEnabled()) {
    statistics.addGetTimeNano(System.nanoTime() - start);
    if (result != null) {
      statistics.increaseCacheHits(1);
      statistics.increaseCacheRemovals(1);
      statistics.addRemoveTimeNano(System.nanoTime() - start);
    }
 else {
      statistics.increaseCacheMisses(1);
    }
  }
  return result;
}

Fixed version (ground truth):
@Override public Object getAndRemove(Data key,String caller){
  final long now=Clock.currentTimeMillis();
  final long start=isStatisticsEnabled() ? System.nanoTime() : 0;
  deleteCacheEntry(key);
  CacheRecord record=records.get(key);
  boolean isExpired=record != null && record.isExpiredAt(now);
  final Object result;
  if (record == null || isExpired) {
    result=null;
  }
 else {
    result=record.getValue();
    deleteRecord(key);
  }
  if (isStatisticsEnabled()) {
    statistics.addGetTimeNanos(System.nanoTime() - start);
    if (result != null) {
      statistics.increaseCacheHits(1);
      statistics.increaseCacheRemovals(1);
      statistics.addRemoveTimeNanos(System.nanoTime() - start);
    }
 else {
      statistics.increaseCacheMisses(1);
    }
  }
  return result;
}
Program: 47690
Project: 47690
Buggy source:
@Override public boolean remove(Data key,Object value,String caller){
  final ExpiryPolicy localExpiryPolicy=defaultExpiryPolicy;
  final long now=Clock.currentTimeMillis();
  final long start=isStatisticsEnabled() ? System.nanoTime() : 0;
  CacheRecord record=records.get(key);
  boolean isExpired=record != null && record.isExpiredAt(now);
  int hitCount=0;
  boolean result=true;
  if (record == null || isExpired) {
    if (isStatisticsEnabled()) {
      statistics.increaseCacheMisses(1);
    }
    result=false;
  }
 else {
    hitCount++;
    if (compare(record.getValue(),value)) {
      deleteCacheEntry(key);
      deleteRecord(key);
    }
 else {
      long expiryTime=updateAccessDuration(record,localExpiryPolicy,now);
      processExpiredEntry(key,record,expiryTime,now);
      result=false;
    }
  }
  if (result && isStatisticsEnabled()) {
    statistics.increaseCacheRemovals(1);
    statistics.addRemoveTimeNano(System.nanoTime() - start);
    if (hitCount == 1) {
      statistics.increaseCacheHits(hitCount);
    }
 else {
      statistics.increaseCacheMisses(1);
    }
  }
  return result;
}

Fixed version (ground truth):
@Override public boolean remove(Data key,Object value,String caller){
  final ExpiryPolicy localExpiryPolicy=defaultExpiryPolicy;
  final long now=Clock.currentTimeMillis();
  final long start=isStatisticsEnabled() ? System.nanoTime() : 0;
  CacheRecord record=records.get(key);
  boolean isExpired=record != null && record.isExpiredAt(now);
  int hitCount=0;
  boolean result=true;
  if (record == null || isExpired) {
    if (isStatisticsEnabled()) {
      statistics.increaseCacheMisses(1);
    }
    result=false;
  }
 else {
    hitCount++;
    if (compare(record.getValue(),value)) {
      deleteCacheEntry(key);
      deleteRecord(key);
    }
 else {
      long expiryTime=updateAccessDuration(record,localExpiryPolicy,now);
      processExpiredEntry(key,record,expiryTime,now);
      result=false;
    }
  }
  if (result && isStatisticsEnabled()) {
    statistics.increaseCacheRemovals(1);
    statistics.addRemoveTimeNanos(System.nanoTime() - start);
    if (hitCount == 1) {
      statistics.increaseCacheHits(hitCount);
    }
 else {
      statistics.increaseCacheMisses(1);
    }
  }
  return result;
}
Program: 47691
Project: 47691
Buggy source:
protected boolean putIfAbsent(Data key,Object value,ExpiryPolicy expiryPolicy,String caller,boolean disableWriteThrough){
  final ExpiryPolicy localExpiryPolicy=expiryPolicy != null ? expiryPolicy : defaultExpiryPolicy;
  final long now=Clock.currentTimeMillis();
  final long start=isStatisticsEnabled() ? System.nanoTime() : 0;
  boolean result;
  CacheRecord record=records.get(key);
  boolean isExpired=processExpiredEntry(key,record,now);
  if (record == null || isExpired) {
    result=createRecordWithExpiry(key,value,localExpiryPolicy,now,disableWriteThrough);
  }
 else {
    result=false;
  }
  if (result && isStatisticsEnabled()) {
    statistics.increaseCachePuts(1);
    statistics.addPutTimeNano(System.nanoTime() - start);
  }
  return result;
}

Fixed version (ground truth):
protected boolean putIfAbsent(Data key,Object value,ExpiryPolicy expiryPolicy,String caller,boolean disableWriteThrough){
  final ExpiryPolicy localExpiryPolicy=expiryPolicy != null ? expiryPolicy : defaultExpiryPolicy;
  final long now=Clock.currentTimeMillis();
  final long start=isStatisticsEnabled() ? System.nanoTime() : 0;
  boolean result;
  CacheRecord record=records.get(key);
  boolean isExpired=processExpiredEntry(key,record,now);
  if (record == null || isExpired) {
    result=createRecordWithExpiry(key,value,localExpiryPolicy,now,disableWriteThrough);
  }
 else {
    result=false;
  }
  if (result && isStatisticsEnabled()) {
    statistics.increaseCachePuts(1);
    statistics.addPutTimeNanos(System.nanoTime() - start);
  }
  return result;
}
Program: 47692
Project: 47692
Buggy source:
@Override public <T>List<Future<T>> invokeAll(Collection<? extends Callable<T>> tasks,long timeout,TimeUnit unit) throws InterruptedException {
  if (unit == null) {
    throw new NullPointerException("String_Node_Str");
  }
  if (tasks == null) {
    throw new NullPointerException("String_Node_Str");
  }
  long timeoutNanos=unit.toNanos(timeout);
  List<Future<T>> futures=new ArrayList<Future<T>>(tasks.size());
  List<Future<T>> result=new ArrayList<Future<T>>(tasks.size());
  boolean done=true;
  try {
    for (    Callable<T> task : tasks) {
      long start=System.nanoTime();
      int partitionId=getTaskPartitionId(task);
      futures.add(submitToPartitionOwner(task,partitionId,true));
      timeoutNanos-=System.nanoTime() - start;
      if (timeoutNanos <= 0L) {
        for (        Future<T> future : futures) {
          result.add(future);
        }
        return result;
      }
    }
    done=wait(timeoutNanos,futures,result);
  }
 catch (  Throwable t) {
    logger.severe(t);
  }
 finally {
    if (!done) {
      cancelAll(result);
    }
    return result;
  }
}

Fixed version (ground truth):
@Override public <T>List<Future<T>> invokeAll(Collection<? extends Callable<T>> tasks,long timeout,TimeUnit unit) throws InterruptedException {
  if (unit == null) {
    throw new NullPointerException("String_Node_Str");
  }
  if (tasks == null) {
    throw new NullPointerException("String_Node_Str");
  }
  long timeoutNanos=unit.toNanos(timeout);
  List<Future<T>> futures=new ArrayList<Future<T>>(tasks.size());
  List<Future<T>> result=new ArrayList<Future<T>>(tasks.size());
  boolean done=true;
  try {
    for (    Callable<T> task : tasks) {
      long start=System.nanoTime();
      int partitionId=getTaskPartitionId(task);
      futures.add(submitToPartitionOwner(task,partitionId,true));
      timeoutNanos-=System.nanoTime() - start;
      if (timeoutNanos <= 0L) {
        for (        Future<T> future : futures) {
          result.add(future);
        }
        return result;
      }
    }
    done=wait(timeoutNanos,futures,result);
    return result;
  }
 catch (  Throwable t) {
    logger.severe(t);
    return result;
  }
 finally {
    if (!done) {
      cancelAll(result);
    }
  }
}