nus-yam/ex-repair huggingface dataset:
Program: 189090
Project: 189090
Buggy source:
/** 
 * Retrieves a cached service instance for an end point that is not currently checked out.  If no idle cached instance is available and the cache is not full, a new one will be created, added to the cache, and then checked out.  Once the checked out instance is no longer in use, it should be returned by calling   {@link #checkIn}.
 * @param endPoint The end point to retrieve a cached service instance for.
 * @return A cached service instance for the requested end point.
 * @throws NoCachedInstancesAvailableException If the cache has reached total maximum capacity, or maximum capacityfor the requested end point, and no connections that aren't already checked out are available.
 */
public S checkOut(ServiceEndPoint endPoint) throws Exception {
  checkNotNull(endPoint);
  _requestCount.incrementAndGet();
  try {
    S service=_pool.borrowObject(endPoint);
    _checkOutRevisions.put(service,_revisionNumber.incrementAndGet());
    return service;
  }
 catch (  NoSuchElementException e) {
    _missCount.incrementAndGet();
    throw new NoCachedInstancesAvailableException();
  }
}

Fixed version (ground truth):
/** 
 * Retrieves a cached service instance for an end point that is not currently checked out.  If no idle cached instance is available and the cache is not full, a new one will be created, added to the cache, and then checked out.  Once the checked out instance is no longer in use, it should be returned by calling   {@link #checkIn}.
 * @param endPoint The end point to retrieve a cached service instance for.
 * @return A service handle that contains a cached service instance for the requested end point.
 * @throws NoCachedInstancesAvailableException If the cache has reached total maximum capacity, or maximum capacityfor the requested end point, and no connections that aren't already checked out are available.
 */
public ServiceHandle<S> checkOut(ServiceEndPoint endPoint) throws Exception {
  checkNotNull(endPoint);
  _requestCount.incrementAndGet();
  try {
    long revision=_revisionNumber.incrementAndGet();
    S service=_pool.borrowObject(endPoint);
    ServiceHandle<S> handle=new ServiceHandle<S>(service,endPoint);
    _checkedOutRevisions.put(handle,revision);
    return handle;
  }
 catch (  NoSuchElementException e) {
    _missCount.incrementAndGet();
    throw new NoCachedInstancesAvailableException();
  }
}
Program: 189091
Project: 189091
Buggy source:
/** 
 * Execute a callback on a specific end point. <p/> NOTE: This method is package private specifically so that   {@link AsyncServicePool} can call it.
 */
<R>R executeOnEndPoint(ServiceEndPoint endPoint,ServiceCallback<S,R> callback) throws Exception {
  S service=null;
  try {
    service=_serviceCache.checkOut(endPoint);
    TimerContext timer=_callbackExecutionTime.time();
    try {
      return callback.call(service);
    }
  finally {
      timer.stop();
    }
  }
 catch (  NoCachedInstancesAvailableException e) {
    LOG.debug("String_Node_Str",endPoint.getId(),e);
    throw e;
  }
catch (  Exception e) {
    if (_serviceFactory.isRetriableException(e)) {
      markEndPointAsBad(endPoint);
      LOG.debug("String_Node_Str",endPoint.getId(),e);
    }
    throw e;
  }
 finally {
    if (service != null) {
      try {
        _serviceCache.checkIn(endPoint,service);
      }
 catch (      Exception e) {
        LOG.warn("String_Node_Str",endPoint.getId(),e.toString());
        LOG.debug("String_Node_Str",e);
      }
    }
  }
}

Fixed version (ground truth):
/** 
 * Execute a callback on a specific end point. <p/> NOTE: This method is package private specifically so that   {@link AsyncServicePool} can call it.
 */
<R>R executeOnEndPoint(ServiceEndPoint endPoint,ServiceCallback<S,R> callback) throws Exception {
  ServiceHandle<S> handle=null;
  try {
    handle=_serviceCache.checkOut(endPoint);
    TimerContext timer=_callbackExecutionTime.time();
    try {
      return callback.call(handle.getService());
    }
  finally {
      timer.stop();
    }
  }
 catch (  NoCachedInstancesAvailableException e) {
    LOG.debug("String_Node_Str",endPoint.getId(),e);
    throw e;
  }
catch (  Exception e) {
    if (_serviceFactory.isRetriableException(e)) {
      markEndPointAsBad(endPoint);
      LOG.debug("String_Node_Str",endPoint.getId(),e);
    }
    throw e;
  }
 finally {
    if (handle != null) {
      try {
        _serviceCache.checkIn(handle);
      }
 catch (      Exception e) {
        LOG.warn("String_Node_Str",endPoint.getId(),e.toString());
        LOG.debug("String_Node_Str",e);
      }
    }
  }
}
Program: 189092
Project: 189092
Buggy source:
/** 
 * Adds a   {@link HostDiscovery} instance to the builder.  The service pool will use this {@code HostDiscovery}instance unless a preceding   {@link HostDiscoverySource} provides a non-null instance of {@code HostDiscovery}. <p> Once this method is called, any subsequent calls to host discovery-related methods on this builder instance are ignored. <p> Note that callers of this method are responsible for calling   {@link HostDiscovery#close} on the passed instance.
 * @param hostDiscovery the host discovery instance to use in the built {@link ServicePool}
 * @return this
 */
public ServicePoolBuilder<S> withHostDiscovery(final HostDiscovery hostDiscovery){
  checkNotNull(hostDiscovery);
  return withHostDiscoverySource(new HostDiscoverySource(){
    @Override public HostDiscovery forService(    String serviceName){
      return hostDiscovery;
    }
  }
);
}

Fixed version (ground truth):
/** 
 * Adds a   {@link HostDiscovery} instance to the builder.  The service pool will use this {@code HostDiscovery}instance unless a preceding   {@link HostDiscoverySource} provides a non-null instance of {@code HostDiscovery}. <p> Once this method is called, any subsequent calls to host discovery-related methods on this builder instance are ignored. <p> Note that callers of this method are responsible for calling   {@link HostDiscovery#close} on the passed instance.
 * @param hostDiscovery the host discovery instance to use in the built {@link ServicePool}
 * @return this
 */
public ServicePoolBuilder<S> withHostDiscovery(final HostDiscovery hostDiscovery){
  checkNotNull(hostDiscovery);
  HostDiscoverySource hostDiscoverySource=new HostDiscoverySource(){
    @Override public HostDiscovery forService(    String serviceName){
      return hostDiscovery;
    }
  }
;
  return withHostDiscoverySourceInternal(hostDiscoverySource,false);
}
Program: 189093
Project: 189093
Buggy source:
/** 
 * Adds a   {@link ZooKeeperConnection} instance to the builder that will be used for host discovery.  The servicepool will use ZooKeeper for host discovery unless a preceding call to {@link #withHostDiscoverySource(HostDiscoverySource)} provides a non-null instance of {@code HostDiscovery}. <p> Once this method is called, any subsequent calls to host discovery-related methods on this builder instance are ignored. <p> Note that using this method will cause the ServicePoolBuilder to construct a   {@code HostDiscovery} when{@link #build()} is called and pass it to the new {@code ServicePool}.  Subsequently calling  {@link ServicePool#close()} will in turn call {@link HostDiscovery#close()} on the passed instance.
 * @param connection the ZooKeeper connection to use for host discovery
 * @return this
 */
public ServicePoolBuilder<S> withZooKeeperHostDiscovery(final ZooKeeperConnection connection){
  checkNotNull(connection);
  return withHostDiscoverySource(new HostDiscoverySource(){
    @Override public HostDiscovery forService(    String serviceName){
      HostDiscovery hostDiscovery=new ZooKeeperHostDiscovery(connection,serviceName);
      _closeHostDiscovery=true;
      return hostDiscovery;
    }
  }
);
}

Fixed version (ground truth):
/** 
 * Adds a   {@link ZooKeeperConnection} instance to the builder that will be used for host discovery.  The servicepool will use ZooKeeper for host discovery unless a preceding call to {@link #withHostDiscoverySource(HostDiscoverySource)} provides a non-null instance of {@code HostDiscovery}. <p> Once this method is called, any subsequent calls to host discovery-related methods on this builder instance are ignored. <p> Note that using this method will cause the ServicePoolBuilder to construct a   {@code HostDiscovery} when{@link #build()} is called and pass it to the new {@code ServicePool}.  Subsequently calling  {@link ServicePool#close()} will in turn call {@link HostDiscovery#close()} on the passed instance.
 * @param connection the ZooKeeper connection to use for host discovery
 * @return this
 */
public ServicePoolBuilder<S> withZooKeeperHostDiscovery(final ZooKeeperConnection connection){
  checkNotNull(connection);
  HostDiscoverySource hostDiscoverySource=new HostDiscoverySource(){
    @Override public HostDiscovery forService(    String serviceName){
      return new ZooKeeperHostDiscovery(connection,serviceName);
    }
  }
;
  return withHostDiscoverySourceInternal(hostDiscoverySource,true);
}
Program: 189094
Project: 189094
Buggy source:
/** 
 * Adds a   {@link HostDiscoverySource} instance to the builder.  Multiple instances of {@code HostDiscoverySource}may be specified.  The service pool will use the first source to return a non-null instance of  {@link HostDiscovery} for the service name provided by the {@link ServiceFactory#getServiceName()} method ofthe factory configured by  {@link #withServiceFactory}. <p> Note that callers of this method are responsible for calling   {@link HostDiscovery#close} on any instancescreated by the  {@code HostDiscoverySource}.
 * @param hostDiscoverySource a host discovery source to use to find the {@link HostDiscovery} when constructingthe  {@link ServicePool}
 * @return this
 */
public ServicePoolBuilder<S> withHostDiscoverySource(HostDiscoverySource hostDiscoverySource){
  _hostDiscoverySources.add(checkNotNull(hostDiscoverySource));
  return this;
}

Fixed version (ground truth):
/** 
 * Adds a   {@link HostDiscoverySource} instance to the builder.  Multiple instances of {@code HostDiscoverySource}may be specified.  The service pool will use the first source to return a non-null instance of  {@link HostDiscovery} for the service name provided by the {@link ServiceFactory#getServiceName()} method ofthe factory configured by  {@link #withServiceFactory}. <p> Note that using this method will cause the ServicePoolBuilder to call  {@link HostDiscoverySource#forService(String serviceName)} when {@link #build()} is called and pass the returned{@link HostDiscovery} to the new {@code ServicePool}.  Subsequently calling   {@link ServicePool#close()} will inturn call  {@link HostDiscovery#close()} on the passed instance.
 * @param hostDiscoverySource a host discovery source to use to find the {@link HostDiscovery} when constructingthe  {@link ServicePool}
 * @return this
 */
public ServicePoolBuilder<S> withHostDiscoverySource(HostDiscoverySource hostDiscoverySource){
  checkNotNull(hostDiscoverySource);
  return withHostDiscoverySourceInternal(hostDiscoverySource,true);
}
Program: 189095
Project: 189095
Buggy source:
@VisibleForTesting ServicePool<S> buildInternal(){
  checkNotNull(_serviceFactory);
  HostDiscovery hostDiscovery=findHostDiscovery(_serviceName);
  try {
    if (_cachingPolicy == null) {
      _cachingPolicy=ServiceCachingPolicyBuilder.NO_CACHING;
    }
    boolean shutdownHealthCheckExecutorOnClose=(_healthCheckExecutor == null);
    if (_healthCheckExecutor == null) {
      ThreadFactory threadFactory=new ThreadFactoryBuilder().setNameFormat(_serviceName + "String_Node_Str").setDaemon(true).build();
      _healthCheckExecutor=Executors.newScheduledThreadPool(DEFAULT_NUM_HEALTH_CHECK_THREADS,threadFactory);
    }
    ServicePool<S> servicePool=new ServicePool<S>(Ticker.systemTicker(),hostDiscovery,_closeHostDiscovery,_serviceFactory,_cachingPolicy,_partitionFilter,_loadBalanceAlgorithm,_healthCheckExecutor,shutdownHealthCheckExecutorOnClose);
    _closeHostDiscovery=false;
    return servicePool;
  }
 catch (  Throwable t) {
    try {
      if (_closeHostDiscovery) {
        hostDiscovery.close();
      }
    }
 catch (    IOException e) {
    }
 finally {
      _closeHostDiscovery=false;
    }
    throw Throwables.propagate(t);
  }
}

Fixed version (ground truth):
@VisibleForTesting ServicePool<S> buildInternal(){
  checkNotNull(_serviceFactory);
  HostDiscovery hostDiscovery=findHostDiscovery(_serviceName);
  boolean shutdownHealthCheckExecutorOnClose=(_healthCheckExecutor == null);
  try {
    if (_cachingPolicy == null) {
      _cachingPolicy=ServiceCachingPolicyBuilder.NO_CACHING;
    }
    if (_healthCheckExecutor == null) {
      ThreadFactory threadFactory=new ThreadFactoryBuilder().setNameFormat(_serviceName + "String_Node_Str").setDaemon(true).build();
      _healthCheckExecutor=Executors.newScheduledThreadPool(DEFAULT_NUM_HEALTH_CHECK_THREADS,threadFactory);
    }
    ServicePool<S> servicePool=new ServicePool<S>(Ticker.systemTicker(),hostDiscovery,_closeHostDiscovery,_serviceFactory,_cachingPolicy,_partitionFilter,_loadBalanceAlgorithm,_healthCheckExecutor,shutdownHealthCheckExecutorOnClose);
    _closeHostDiscovery=false;
    return servicePool;
  }
 catch (  Throwable t) {
    if (shutdownHealthCheckExecutorOnClose) {
      _healthCheckExecutor.shutdownNow();
    }
    try {
      if (_closeHostDiscovery) {
        hostDiscovery.close();
      }
    }
 catch (    IOException e) {
    }
 finally {
      _closeHostDiscovery=false;
    }
    throw Throwables.propagate(t);
  }
}
Program: 189096
Project: 189096
Buggy source:
@Override public HostDiscovery forService(String serviceName){
  HostDiscovery hostDiscovery=new ZooKeeperHostDiscovery(connection,serviceName);
  _closeHostDiscovery=true;
  return hostDiscovery;
}

Fixed version (ground truth):
@Override public HostDiscovery forService(String serviceName){
  HostDiscovery hostDiscovery=_wrappedSource.forService(serviceName);
  if (hostDiscovery != null) {
    _closeHostDiscovery=true;
  }
  return hostDiscovery;
}
Program: 189097
Project: 189097
Buggy source:
@Override public void close(){
  _batchHealthChecksFuture.cancel(true);
  _hostDiscovery.removeListener(_hostDiscoveryListener);
  if (_closeHostDiscovery) {
    try {
      _hostDiscovery.close();
    }
 catch (    IOException e) {
    }
  }
  _metrics.close();
  if (_shutdownHealthCheckExecutorOnClose) {
    _healthCheckExecutor.shutdownNow();
  }
}

Fixed version (ground truth):
@Override public void close(){
  _batchHealthChecksFuture.cancel(true);
  _hostDiscovery.removeListener(_hostDiscoveryListener);
  if (_cleanupHostDiscoveryOnClose) {
    try {
      _hostDiscovery.close();
    }
 catch (    IOException e) {
    }
  }
  _metrics.close();
  if (_shutdownHealthCheckExecutorOnClose) {
    _healthCheckExecutor.shutdownNow();
  }
}
Program: 189099
Project: 189099
Buggy source:
/** 
 * Adds a   {@link ZooKeeperConnection} instance to the builder that will be used for host discovery.  The servicepool will use ZooKeeper for host discovery unless a preceding call to {@link #withHostDiscoverySource(HostDiscoverySource)} provides a non-null instance of {@code HostDiscovery}. <p> Once this method is called, any subsequent calls to host discovery-related methods on this builder instance are ignored. <p> Note that using this method will cause the ServicePoolBuilder to construct a   {@code HostDiscovery} when{@link #build()} is called and pass it to the new {@code ServicePool}.  Subsequently calling  {@link ServicePool#close()} pool will in turn call {@link HostDiscovery#close()} on the passed instance.
 * @param connection the ZooKeeper connection to use for host discovery
 * @return this
 */
public ServicePoolBuilder<S> withZooKeeperHostDiscovery(final ZooKeeperConnection connection){
  checkNotNull(connection);
  return withHostDiscoverySource(new HostDiscoverySource(){
    @Override public HostDiscovery forService(    String serviceName){
      HostDiscovery hostDiscovery=new ZooKeeperHostDiscovery(connection,serviceName);
      _closeHostDiscovery=true;
      return hostDiscovery;
    }
  }
);
}

Fixed version (ground truth):
/** 
 * Adds a   {@link ZooKeeperConnection} instance to the builder that will be used for host discovery.  The servicepool will use ZooKeeper for host discovery unless a preceding call to {@link #withHostDiscoverySource(HostDiscoverySource)} provides a non-null instance of {@code HostDiscovery}. <p> Once this method is called, any subsequent calls to host discovery-related methods on this builder instance are ignored. <p> Note that using this method will cause the ServicePoolBuilder to construct a   {@code HostDiscovery} when{@link #build()} is called and pass it to the new {@code ServicePool}.  Subsequently calling  {@link ServicePool#close()} will in turn call {@link HostDiscovery#close()} on the passed instance.
 * @param connection the ZooKeeper connection to use for host discovery
 * @return this
 */
public ServicePoolBuilder<S> withZooKeeperHostDiscovery(final ZooKeeperConnection connection){
  checkNotNull(connection);
  return withHostDiscoverySource(new HostDiscoverySource(){
    @Override public HostDiscovery forService(    String serviceName){
      HostDiscovery hostDiscovery=new ZooKeeperHostDiscovery(connection,serviceName);
      _closeHostDiscovery=true;
      return hostDiscovery;
    }
  }
);
}
Program: 189100
Project: 189100
Buggy source:
@VisibleForTesting ServicePool<S> buildInternal(){
  checkNotNull(_serviceFactory);
  HostDiscovery hostDiscovery=findHostDiscovery(_serviceName);
  try {
    if (_cachingPolicy == null) {
      _cachingPolicy=ServiceCachingPolicyBuilder.NO_CACHING;
    }
    boolean shutdownHealthCheckExecutorOnClose=(_healthCheckExecutor == null);
    if (_healthCheckExecutor == null) {
      ThreadFactory threadFactory=new ThreadFactoryBuilder().setNameFormat(_serviceName + "String_Node_Str").setDaemon(true).build();
      _healthCheckExecutor=Executors.newScheduledThreadPool(DEFAULT_NUM_HEALTH_CHECK_THREADS,threadFactory);
    }
    ServicePool<S> servicePool=new ServicePool<S>(Ticker.systemTicker(),hostDiscovery,_closeHostDiscovery,_serviceFactory,_cachingPolicy,_partitionFilter,_loadBalanceAlgorithm,_healthCheckExecutor,shutdownHealthCheckExecutorOnClose);
    _closeHostDiscovery=false;
    return servicePool;
  }
 catch (  Throwable t) {
    try {
      if (_closeHostDiscovery) {
        hostDiscovery.close();
      }
    }
 catch (    IOException e) {
    }
    throw Throwables.propagate(t);
  }
}

Fixed version (ground truth):
@VisibleForTesting ServicePool<S> buildInternal(){
  checkNotNull(_serviceFactory);
  HostDiscovery hostDiscovery=findHostDiscovery(_serviceName);
  try {
    if (_cachingPolicy == null) {
      _cachingPolicy=ServiceCachingPolicyBuilder.NO_CACHING;
    }
    boolean shutdownHealthCheckExecutorOnClose=(_healthCheckExecutor == null);
    if (_healthCheckExecutor == null) {
      ThreadFactory threadFactory=new ThreadFactoryBuilder().setNameFormat(_serviceName + "String_Node_Str").setDaemon(true).build();
      _healthCheckExecutor=Executors.newScheduledThreadPool(DEFAULT_NUM_HEALTH_CHECK_THREADS,threadFactory);
    }
    ServicePool<S> servicePool=new ServicePool<S>(Ticker.systemTicker(),hostDiscovery,_closeHostDiscovery,_serviceFactory,_cachingPolicy,_partitionFilter,_loadBalanceAlgorithm,_healthCheckExecutor,shutdownHealthCheckExecutorOnClose);
    _closeHostDiscovery=false;
    return servicePool;
  }
 catch (  Throwable t) {
    try {
      if (_closeHostDiscovery) {
        hostDiscovery.close();
      }
    }
 catch (    IOException e) {
    }
 finally {
      _closeHostDiscovery=false;
    }
    throw Throwables.propagate(t);
  }
}
Program: 189101
Project: 189101
Buggy source:
@After public void teardown(){
  for (  ServicePool<Service> pool : _pools) {
    pool.close();
  }
  try {
    _hostDiscovery.close();
  }
 catch (  IOException e) {
  }
}

Fixed version (ground truth):
@After public void teardown() throws IOException {
  for (  ServicePool<Service> pool : _pools) {
    pool.close();
  }
  _hostDiscovery.close();
}
Program: 189102
Project: 189102
Buggy source:
@After public void teardown(){
  _pool.close();
  try {
    _hostDiscovery.close();
  }
 catch (  IOException e) {
  }
}

Fixed version (ground truth):
@After public void teardown() throws IOException {
  _pool.close();
  _hostDiscovery.close();
}
Program: 189103
Project: 189103
Buggy source:
@Test public void testMembershipCheck(){
  _registry.register(FOO);
  assertTrue(waitUntilSize(_discovery.getHosts(),1));
  assertTrue(_discovery.contains(FOO));
  assertFalse(_discovery.contains(BAR));
}

Fixed version (ground truth):
@Test public void testMembershipCheck(){
  _registry.register(FOO);
  _registry.register(BAR);
  assertTrue(waitUntilSize(_discovery.getHosts(),1));
  assertTrue(_discovery.contains(FOO));
  assertFalse(_discovery.contains(BAR));
}
Program: 189104
Project: 189104
Buggy source:
/** 
 * Convert a <code>ServiceEndPoint</code> into the path in ZooKeeper where it will be registered.
 * @param endPoint The service end point to get the ZooKeeper path for.
 * @return The ZooKeeper path.
 */
private static String makeEndPointPath(ServiceEndPoint endPoint){
  String servicePath=makeServicePath(endPoint.getServiceName());
  String id=endPoint.getId();
  return ZKPaths.makePath(servicePath,id);
}

Fixed version (ground truth):
/** 
 * Convert a <code>ServiceEndPoint</code> into the path in ZooKeeper where it will be registered.
 * @param endPoint The service end point to get the ZooKeeper path for.
 * @return The ZooKeeper path.
 */
@VisibleForTesting static String makeEndPointPath(ServiceEndPoint endPoint){
  String servicePath=makeServicePath(endPoint.getServiceName());
  String id=endPoint.getId();
  return ZKPaths.makePath(servicePath,id);
}
Program: 189105
Project: 189105
Buggy source:
public ZooKeeperServiceRegistry(ZooKeeperConnection connection){
  checkNotNull(connection);
  _zooKeeperConnection=connection;
}

Fixed version (ground truth):
@VisibleForTesting ZooKeeperServiceRegistry(NodeFactory nodeFactory){
  _nodeFactory=checkNotNull(nodeFactory);
}
Program: 189106
Project: 189106
Buggy source:
/** 
 * {@inheritDoc} 
 */
@Override public void unregister(ServiceEndPoint endPoint){
  checkState(!_closed);
  checkNotNull(endPoint);
  String path=makeEndPointPath(endPoint);
  ZooKeeperPersistentEphemeralNode node=_nodes.remove(path);
  if (node != null) {
    node.close(10,TimeUnit.SECONDS);
  }
}

Fixed version (ground truth):
/** 
 * {@inheritDoc} 
 */
@Override public void unregister(ServiceEndPoint endPoint){
  checkState(!_closed);
  checkNotNull(endPoint);
  String path=makeEndPointPath(endPoint);
  ZooKeeperPersistentEphemeralNode node=_nodes.remove(path);
  if (node != null) {
    closeNode(node);
  }
}
Program: 189107
Project: 189107
Buggy source:
@Override public synchronized void close() throws IOException {
  if (_closed) {
    return;
  }
  _closed=true;
  for (  ZooKeeperPersistentEphemeralNode node : _nodes.values()) {
    node.close(10,TimeUnit.SECONDS);
  }
  _nodes.clear();
}

Fixed version (ground truth):
@Override public synchronized void close() throws IOException {
  if (_closed) {
    return;
  }
  _closed=true;
  for (  ZooKeeperPersistentEphemeralNode node : _nodes.values()) {
    closeNode(node);
  }
  _nodes.clear();
}
Program: 189108
Project: 189108
Buggy source:
@VisibleForTesting void register(ServiceEndPoint endPoint,boolean includeRegistrationTime){
  checkState(!_closed);
  checkNotNull(endPoint);
  Map<String,Object> registrationData=Maps.newHashMap();
  if (includeRegistrationTime) {
    DateTime now=DateTime.now().toDateTime(DateTimeZone.UTC);
    registrationData.put("String_Node_Str",ISO8601.print(now));
  }
  byte[] data=ServiceEndPointJsonCodec.toJson(endPoint,registrationData).getBytes(Charsets.UTF_8);
  checkState(data.length < MAX_DATA_SIZE,"String_Node_Str");
  String path=makeEndPointPath(endPoint);
  _nodes.put(path,new ZooKeeperPersistentEphemeralNode(_zooKeeperConnection,path,data,CreateMode.EPHEMERAL));
}

Fixed version (ground truth):
@VisibleForTesting void register(ServiceEndPoint endPoint,boolean includeRegistrationTime){
  checkState(!_closed);
  checkNotNull(endPoint);
  Map<String,Object> registrationData=Maps.newHashMap();
  if (includeRegistrationTime) {
    DateTime now=DateTime.now().toDateTime(DateTimeZone.UTC);
    registrationData.put("String_Node_Str",ISO8601.print(now));
  }
  byte[] data=ServiceEndPointJsonCodec.toJson(endPoint,registrationData).getBytes(Charsets.UTF_8);
  checkState(data.length < MAX_DATA_SIZE,"String_Node_Str");
  String path=makeEndPointPath(endPoint);
  ZooKeeperPersistentEphemeralNode oldNode=_nodes.put(path,_nodeFactory.create(path,data));
  if (oldNode != null) {
    closeNode(oldNode);
  }
}
Program: 189109
Project: 189109
Buggy source:
@Test public void testDuplicateRegister() throws Exception {
  CuratorFramework curator=newCurator();
  _registry.register(FOO);
  _registry.register(FOO);
  assertRegistered(FOO,curator);
}

Fixed version (ground truth):
@Test public void testDuplicateRegister() throws Exception {
  _registry.register(FOO);
  _registry.register(FOO);
  verify(_factoryMock,times(2)).create(eq(FOO_PATH),Matchers.<byte[]>any());
  verify(_nodeMocks.get(0)).close(anyLong(),any(TimeUnit.class));
}
Program: 189110
Project: 189110
Buggy source:
@Test public void testEmptyPayload(){
  _registry.register(newEndPoint("String_Node_Str","String_Node_Str","String_Node_Str"),false);
}

Fixed version (ground truth):
@Test public void testEmptyPayload(){
  _registry.register(newEndPoint(FOO.getServiceName(),FOO.getId(),"String_Node_Str"),false);
}
Program: 189111
Project: 189111
Buggy source:
@Test public void testRegister() throws Exception {
  CuratorFramework curator=newCurator();
  _registry.register(FOO);
  assertRegistered(FOO,curator);
}

Fixed version (ground truth):
@Test public void testRegister() throws Exception {
  _registry.register(FOO);
  ArgumentCaptor<byte[]> dataCaptor=ArgumentCaptor.forClass(byte[].class);
  verify(_factoryMock).create(eq(FOO_PATH),dataCaptor.capture());
  assertEquals(FOO,ServiceEndPointJsonCodec.fromJson(new String(dataCaptor.getValue())));
  verify(_nodeMocks.get(0),never()).close(anyLong(),any(TimeUnit.class));
}
Program: 189112
Project: 189112
Buggy source:
@Test public void testUnregister() throws Exception {
  CuratorFramework curator=newCurator();
  _registry.register(FOO);
  String path=_registry.getRegisteredEndPointPath(FOO);
  _registry.unregister(FOO);
  assertNodeDoesNotExist(path,curator);
}

Fixed version (ground truth):
@Test public void testUnregister() throws Exception {
  _registry.register(FOO);
  _registry.unregister(FOO);
  verify(_nodeMocks.get(0)).close(anyLong(),any(TimeUnit.class));
}
Program: 189113
Project: 189113
Buggy source:
@Test public void testDuplicateUnregister() throws Exception {
  CuratorFramework curator=newCurator();
  _registry.register(FOO);
  String path=_registry.getRegisteredEndPointPath(FOO);
  _registry.unregister(FOO);
  _registry.unregister(FOO);
  assertNodeDoesNotExist(path,curator);
}

Fixed version (ground truth):
@Test public void testDuplicateUnregister() throws Exception {
  _registry.register(FOO);
  _registry.unregister(FOO);
  _registry.unregister(FOO);
}
Program: 189114
Project: 189114
Buggy source:
@Test public void testServiceNodeIsDeletedWhenRegistryIsClosed() throws Exception {
  CuratorFramework curator=newCurator();
  _registry.register(FOO);
  String path=_registry.getRegisteredEndPointPath(FOO);
  WatchTrigger deletionTrigger=new WatchTrigger();
  curator.checkExists().usingWatcher(deletionTrigger).forPath(path);
  _registry.close();
  assertTrue(deletionTrigger.firedWithin(10,TimeUnit.SECONDS));
}

Fixed version (ground truth):
@Test public void testServiceNodeIsDeletedWhenRegistryIsClosed() throws Exception {
  _registry.register(FOO);
  _registry.close();
  for (  ZooKeeperPersistentEphemeralNode node : _nodeMocks) {
    verify(node).close(anyLong(),any(TimeUnit.class));
  }
}
Program: 189115
Project: 189115
Buggy source:
@Before public void setup() throws Exception {
  super.setup();
  _registry=new ZooKeeperServiceRegistry(newMockZooKeeperConnection(newCurator()));
}

Fixed version (ground truth):
@Before public void setup(){
  when(_factoryMock.create(eq(FOO_PATH),Matchers.<byte[]>any())).thenAnswer(new Answer<ZooKeeperPersistentEphemeralNode>(){
    @Override public ZooKeeperPersistentEphemeralNode answer(    InvocationOnMock invocationOnMock){
      ZooKeeperPersistentEphemeralNode mock=mock(ZooKeeperPersistentEphemeralNode.class);
      _nodeMocks.add(mock);
      return mock;
    }
  }
);
}
Program: 189116
Project: 189116
Buggy source:
@Test public void testUnregisterWithoutFirstRegistering() throws Exception {
  _registry.unregister(FOO);
}

Fixed version (ground truth):
@Test public void testUnregisterWithoutFirstRegistering() throws Exception {
  _registry.unregister(FOO);
  verify(_factoryMock,never()).create(eq(FOO_PATH),Matchers.<byte[]>any());
}
Program: 189117
Project: 189117
Buggy source:
@After public void teardown() throws Exception {
  _registry.close();
  super.teardown();
}

Fixed version (ground truth):
@After public void teardown() throws Exception {
  _registry.close();
}
Program: 189118
Project: 189118
Buggy source:
@Override public int hashCode(){
  int result=owner.hashCode();
  result=31 * result + related.hashCode();
  result=31 * result + type;
  return result;
}

Fixed version (ground truth):
@Override public int hashCode(){
  int result=owner != null ? owner.hashCode() : 0;
  result=31 * result + (related != null ? related.hashCode() : 0);
  result=31 * result + type;
  return result;
}
Program: 189119
Project: 189119
Buggy source:
public boolean equals(IssueRelationship that){
  if (type != that.type) {
    return false;
  }
  if (!owner.equals(that.owner)) {
    return false;
  }
  if (!related.equals(that.related)) {
    return false;
  }
  return true;
}

Fixed version (ground truth):
public boolean equals(IssueRelationship that){
  if (type != that.type) {
    return false;
  }
  if (owner != null ? !owner.equals(that.owner) : that.owner != null) {
    return false;
  }
  if (related != null ? !related.equals(that.related) : that.related != null) {
    return false;
  }
  return true;
}
Program: 189120
Project: 189120
Buggy source:
protected Event getUpdateEvent(Comment comment){
  return new CompleteMilestoneEvent(commentable,commentable.getProject(),getSession().getUser(),comment);
}

Fixed version (ground truth):
@Override protected Event getUpdateEvent(Comment comment){
  return new CompleteMilestoneEvent(commentable,commentable.getProject(),getSession().getUser(),comment);
}
Program: 189121
Project: 189121
Buggy source:
protected void layoutChild(Form form){
  setSubmitLabel("String_Node_Str");
}

Fixed version (ground truth):
@Override protected void layoutChild(Form form){
  setSubmitLabel("String_Node_Str");
}
Program: 189122
Project: 189122
Buggy source:
protected void submitChild(Comment comment){
  commentable.setCompletedDate(new Date());
  if (commentable.getGroup() != null) {
    checkGroupCompletion(commentable.getGroup());
  }
}

Fixed version (ground truth):
@Override protected void submitChild(Comment comment){
  commentable.setCompletedDate(new Date());
  if (commentable.getGroup() != null) {
    checkGroupCompletion(commentable.getGroup());
  }
}
Program: 189123
Project: 189123
Buggy source:
protected Event getUpdateEvent(Comment comment){
  return new UpdateMilestoneEvent(commentable,commentable.getProject(),getSession().getUser(),comment,"String_Node_Str");
}

Fixed version (ground truth):
@Override protected Event getUpdateEvent(Comment comment){
  return new UpdateMilestoneEvent(commentable,commentable.getProject(),getSession().getUser(),comment,"String_Node_Str");
}
Program: 189124
Project: 189124
Buggy source:
protected void layoutChild(Form form){
  setSubmitLabel("String_Node_Str");
}

Fixed version (ground truth):
@Override protected void layoutChild(Form form){
  setSubmitLabel("String_Node_Str");
}
Program: 189125
Project: 189125
Buggy source:
protected void submitChild(){
  commentable.setCompletedDate(null);
  if (commentable.getGroup() != null) {
    commentable.getGroup().setCompletedDate(null);
  }
}

Fixed version (ground truth):
@Override protected void submitChild(Comment comment){
  commentable.setCompletedDate(null);
  if (commentable.getGroup() != null) {
    commentable.getGroup().setCompletedDate(null);
  }
}
Program: 189126
Project: 189126
Buggy source:
public IssuesApplication(){
  links=new LinkedList<MenuLink>();
  links.add(menuItemCreate);
  eventTypes=new LinkedList<String>();
  eventTypes.add("String_Node_Str");
  eventTypes.add("String_Node_Str");
  eventTypes.add("String_Node_Str");
  eventTypes.add("String_Node_Str");
  eventTypes.add("String_Node_Str");
}

Fixed version (ground truth):
public IssuesApplication(){
  links=new LinkedList<MenuLink>();
  links.add(menuItemCreate);
  eventTypes=new LinkedList<String>();
  eventTypes.add("String_Node_Str");
  eventTypes.add("String_Node_Str");
  eventTypes.add("String_Node_Str");
  eventTypes.add("String_Node_Str");
  eventTypes.add("String_Node_Str");
  eventTypes.add("String_Node_Str");
}
Program: 189127
Project: 189127
Buggy source:
public Class[] getPersistantClasses(){
  return new Class[]{CloseIssueEvent.class,CreateIssueEvent.class,UpdateIssueEvent.class,CommentEvent.class,ProgressEvent.class};
}

Fixed version (ground truth):
public Class[] getPersistantClasses(){
  return new Class[]{CloseIssueEvent.class,CreateIssueEvent.class,UpdateIssueEvent.class,ResolveIssueEvent.class,CommentEvent.class,ProgressEvent.class};
}
Program: 189128
Project: 189128
Buggy source:
protected Event getUpdateEvent(Comment comment){
  return new UpdateIssueEvent(getIssue(),getIssue().getProject(),getSession().getUser(),comment,"String_Node_Str");
}

Fixed version (ground truth):
protected Event getUpdateEvent(Comment comment){
  return new ResolveIssueEvent(getIssue(),getIssue().getProject(),getSession().getUser(),comment);
}
Program: 189129
Project: 189129
Buggy source:
protected boolean isAndroidProject(Project project){
  if (!(project instanceof EclipseProject)) {
    return false;
  }
  EclipseProject eclipse=((EclipseProject)project);
  log.debug("String_Node_Str" + eclipse.getNature());
  String nature="String_Node_Str";
  if (eclipse.getNature() != null) {
    nature=eclipse.getNature().substring(eclipse.getNature().lastIndexOf('.') + 1);
  }
  return "String_Node_Str".equals(nature);
}

Fixed version (ground truth):
protected boolean isAndroidProject(Project project){
  if (!(project instanceof EclipseProject)) {
    return false;
  }
  EclipseProject eclipse=((EclipseProject)project);
  log.debug("String_Node_Str" + eclipse.getNature());
  String nature="String_Node_Str";
  if (eclipse.getNature() != null) {
    nature=eclipse.getNature().substring(eclipse.getNature().lastIndexOf('.') + 1);
    nature.trim();
  }
  return "String_Node_Str".equals(nature);
}
Program: 189130
Project: 189130
Buggy source:
private String getNatureTypeName(){
  if (nature == null || nature.trim().length() == 0) {
    return null;
  }
  String ret=nature;
  int lastDot=ret.lastIndexOf('.');
  if (lastDot > -1) {
    ret=ret.substring(lastDot + 1);
  }
  if (ret.endsWith("String_Node_Str")) {
    ret=ret.substring(0,ret.length() - 6);
  }
  return ret.substring(0,1).toUpperCase() + ret.substring(1);
}

Fixed version (ground truth):
private String getNatureTypeName(){
  if (nature == null || nature.trim().length() == 0) {
    return null;
  }
  String ret=nature.trim();
  int lastDot=ret.lastIndexOf('.');
  if (lastDot > -1) {
    ret=ret.substring(lastDot + 1);
  }
  if (ret.toLowerCase().endsWith("String_Node_Str")) {
    ret=ret.substring(0,ret.length() - 6);
  }
  return ret.substring(0,1).toUpperCase() + ret.substring(1);
}
Program: 189131
Project: 189131
Buggy source:
protected boolean isAndroidProject(Project project){
  if (!(project instanceof EclipseProject)) {
    return false;
  }
  EclipseProject eclipse=((EclipseProject)project);
  log.debug("String_Node_Str" + eclipse.getNature());
  String nature="String_Node_Str";
  if (eclipse.getNature() != null) {
    nature=eclipse.getNature().substring(eclipse.getNature().lastIndexOf('.') + 1);
  }
  return "String_Node_Str".equals(nature);
}

Fixed version (ground truth):
protected boolean isAndroidProject(Project project){
  if (!(project instanceof EclipseProject)) {
    return false;
  }
  EclipseProject eclipse=((EclipseProject)project);
  log.debug("String_Node_Str" + eclipse.getNature());
  String nature="String_Node_Str";
  if (eclipse.getNature() != null) {
    nature=eclipse.getNature().substring(eclipse.getNature().lastIndexOf('.') + 1);
    nature.trim();
  }
  return "String_Node_Str".equals(nature);
}
Program: 189132
Project: 189132
Buggy source:
private String getNatureTypeName(){
  if (nature == null || nature.trim().length() == 0) {
    return null;
  }
  String ret=nature;
  int lastDot=ret.lastIndexOf('.');
  if (lastDot > -1) {
    ret=ret.substring(lastDot + 1);
  }
  if (ret.endsWith("String_Node_Str")) {
    ret=ret.substring(0,ret.length() - 6);
  }
  return ret.substring(0,1).toUpperCase() + ret.substring(1);
}

Fixed version (ground truth):
private String getNatureTypeName(){
  if (nature == null || nature.trim().length() == 0) {
    return null;
  }
  String ret=nature.trim();
  int lastDot=ret.lastIndexOf('.');
  if (lastDot > -1) {
    ret=ret.substring(lastDot + 1);
  }
  if (ret.toLowerCase().endsWith("String_Node_Str")) {
    ret=ret.substring(0,ret.length() - 6);
  }
  return ret.substring(0,1).toUpperCase() + ret.substring(1);
}
Program: 189133
Project: 189133
Buggy source:
public void setPreference(String key,Date value){
  DateFormat dateFormat=DateFormat.getDateTimeInstance(DateFormat.LONG,DateFormat.LONG,Locale.ENGLISH);
  setPreference(key,dateFormat.format(value));
}

Fixed version (ground truth):
public void setPreference(String key,Date value){
  if (value == null) {
    setPreference(key,(String)null);
    return;
  }
  DateFormat dateFormat=DateFormat.getDateTimeInstance(DateFormat.LONG,DateFormat.LONG,Locale.ENGLISH);
  setPreference(key,dateFormat.format(value));
}
Program: 189134
Project: 189134
Buggy source:
@Override public int compare(RenderedMatch renderedMatch,RenderedMatch renderedMatch2){
  int length1=renderedMatch.getEnd() - renderedMatch.getStart();
  int length2=renderedMatch2.getEnd() - renderedMatch.getEnd();
  return length1 - length2;
}

Fixed version (ground truth):
@Override public int compare(RenderedMatch renderedMatch,RenderedMatch renderedMatch2){
  int length1=renderedMatch.getEnd() - renderedMatch.getStart();
  int length2=renderedMatch2.getEnd() - renderedMatch.getEnd();
  return length2 - length1;
}
Program: 189135
Project: 189135
Buggy source:
void renderField(String field,String content,List<String> matches,StringBuffer out){
  List<RenderedMatch> renderedMatches=new LinkedList<RenderedMatch>();
  for (  String match : matches) {
    renderedMatches.addAll(renderMatch(field,content,match));
  }
  if (renderedMatches.size() == 0) {
    out.append("String_Node_Str");
    return;
  }
  renderedMatches=findNonSubstringMatches(renderedMatches);
  Collections.sort(renderedMatches);
  int renderStart=renderedMatches.get(0).getStart() - BUFFER_CHARS;
  if (renderStart <= 0) {
    renderStart=0;
  }
  int renderEnd=renderedMatches.get(renderedMatches.size() - 1).getEnd() + BUFFER_CHARS;
  if (renderEnd >= content.length()) {
    renderEnd=content.length();
  }
  if (renderStart > 0) {
    out.append("String_Node_Str");
  }
  int curr=renderStart;
  for (  RenderedMatch render : renderedMatches) {
    int myStart=render.getStart();
    if (myStart - curr < (BUFFER_CHARS * 2)) {
      out.append(escape(content.substring(curr,myStart)));
    }
 else {
      out.append(escape(content.substring(curr,curr + BUFFER_CHARS)));
      out.append("String_Node_Str");
      out.append(escape(content.substring(myStart - BUFFER_CHARS,myStart)));
    }
    out.append(render.getRender());
    curr=render.getEnd();
  }
  out.append(escape(content.substring(curr,renderEnd)));
  if (renderEnd < content.length()) {
    out.append("String_Node_Str");
  }
}

Fixed version (ground truth):
void renderField(String field,String content,List<String> matches,StringBuffer out){
  List<RenderedMatch> renderedMatches=new LinkedList<RenderedMatch>();
  for (  String match : matches) {
    renderedMatches.addAll(renderMatch(field,content,match));
  }
  if (renderedMatches.size() == 0) {
    out.append("String_Node_Str");
    return;
  }
  renderedMatches=findNonSubstringMatches(renderedMatches);
  Collections.sort(renderedMatches);
  int renderStart=0;
  int renderEnd=content.length();
  if (renderedMatches.size() > 0) {
    renderStart=renderedMatches.get(0).getStart() - BUFFER_CHARS;
    if (renderStart <= 0) {
      renderStart=0;
    }
    renderEnd=renderedMatches.get(renderedMatches.size() - 1).getEnd() + BUFFER_CHARS;
    if (renderEnd >= content.length()) {
      renderEnd=content.length();
    }
  }
  if (renderStart > 0) {
    out.append("String_Node_Str");
  }
  int curr=renderStart;
  for (  RenderedMatch render : renderedMatches) {
    int myStart=render.getStart();
    if (myStart - curr < (BUFFER_CHARS * 2)) {
      out.append(escape(content.substring(curr,myStart)));
    }
 else {
      out.append(escape(content.substring(curr,curr + BUFFER_CHARS)));
      out.append("String_Node_Str");
      out.append(escape(content.substring(myStart - BUFFER_CHARS,myStart)));
    }
    out.append(render.getRender());
    curr=render.getEnd();
  }
  out.append(escape(content.substring(curr,renderEnd)));
  if (renderEnd < content.length()) {
    out.append("String_Node_Str");
  }
}
Program: 189136
Project: 189136
Buggy source:
private List<RenderedMatch> findNonSubstringMatches(List<RenderedMatch> renderedMatches){
  Collections.sort(renderedMatches,new Comparator<RenderedMatch>(){
    @Override public int compare(    RenderedMatch renderedMatch,    RenderedMatch renderedMatch2){
      int length1=renderedMatch.getEnd() - renderedMatch.getStart();
      int length2=renderedMatch2.getEnd() - renderedMatch.getEnd();
      return length1 - length2;
    }
  }
);
  Iterator<RenderedMatch> matchIter=renderedMatches.iterator();
  ArrayList<RenderedMatch> out=new ArrayList<RenderedMatch>(renderedMatches.size());
  while (matchIter.hasNext()) {
    RenderedMatch match=matchIter.next();
    boolean addMatch=true;
    for (    RenderedMatch supermatch : out) {
      if (match.getStart() >= supermatch.getStart() && match.getEnd() <= supermatch.getEnd()) {
        addMatch=false;
        break;
      }
    }
    if (addMatch) {
      out.add(match);
    }
  }
  return out;
}

Fixed version (ground truth):
private List<RenderedMatch> findNonSubstringMatches(List<RenderedMatch> renderedMatches){
  Collections.sort(renderedMatches,new Comparator<RenderedMatch>(){
    @Override public int compare(    RenderedMatch renderedMatch,    RenderedMatch renderedMatch2){
      int length1=renderedMatch.getEnd() - renderedMatch.getStart();
      int length2=renderedMatch2.getEnd() - renderedMatch.getEnd();
      return length2 - length1;
    }
  }
);
  ArrayList<RenderedMatch> out=new ArrayList<RenderedMatch>(renderedMatches.size());
  for (  RenderedMatch match : renderedMatches) {
    boolean addMatch=true;
    Iterator<RenderedMatch> superIter=out.iterator();
    while (superIter.hasNext()) {
      RenderedMatch supermatch=superIter.next();
      if (match.getStart() >= supermatch.getStart() && match.getEnd() <= supermatch.getEnd()) {
        addMatch=false;
        break;
      }
 else       if ((match.getStart() > supermatch.getStart() && match.getStart() < supermatch.getEnd()) || (match.getEnd() > supermatch.getStart() && match.getEnd() < supermatch.getEnd())) {
        addMatch=false;
        superIter.remove();
        break;
      }
    }
    if (addMatch) {
      out.add(match);
    }
  }
  return out;
}
Program: 189137
Project: 189137
Buggy source:
@Override public int compare(RenderedMatch renderedMatch,RenderedMatch renderedMatch2){
  int length1=renderedMatch.getEnd() - renderedMatch.getStart();
  int length2=renderedMatch2.getEnd() - renderedMatch.getEnd();
  return length2 - length1;
}

Fixed version (ground truth):
@Override public int compare(RenderedMatch renderedMatch,RenderedMatch renderedMatch2){
  int length1=renderedMatch.getEnd() - renderedMatch.getStart();
  int length2=renderedMatch2.getEnd() - renderedMatch2.getStart();
  return length2 - length1;
}
Program: 189138
Project: 189138
Buggy source:
private List<RenderedMatch> findNonSubstringMatches(List<RenderedMatch> renderedMatches){
  Collections.sort(renderedMatches,new Comparator<RenderedMatch>(){
    @Override public int compare(    RenderedMatch renderedMatch,    RenderedMatch renderedMatch2){
      int length1=renderedMatch.getEnd() - renderedMatch.getStart();
      int length2=renderedMatch2.getEnd() - renderedMatch.getEnd();
      return length2 - length1;
    }
  }
);
  ArrayList<RenderedMatch> out=new ArrayList<RenderedMatch>(renderedMatches.size());
  for (  RenderedMatch match : renderedMatches) {
    boolean addMatch=true;
    Iterator<RenderedMatch> superIter=out.iterator();
    while (superIter.hasNext()) {
      RenderedMatch supermatch=superIter.next();
      if (match.getStart() >= supermatch.getStart() && match.getEnd() <= supermatch.getEnd()) {
        addMatch=false;
        break;
      }
 else       if ((match.getStart() > supermatch.getStart() && match.getStart() < supermatch.getEnd()) || (match.getEnd() > supermatch.getStart() && match.getEnd() < supermatch.getEnd())) {
        addMatch=false;
        superIter.remove();
        break;
      }
    }
    if (addMatch) {
      out.add(match);
    }
  }
  return out;
}

Fixed version (ground truth):
private List<RenderedMatch> findNonSubstringMatches(List<RenderedMatch> renderedMatches){
  Collections.sort(renderedMatches,new Comparator<RenderedMatch>(){
    @Override public int compare(    RenderedMatch renderedMatch,    RenderedMatch renderedMatch2){
      int length1=renderedMatch.getEnd() - renderedMatch.getStart();
      int length2=renderedMatch2.getEnd() - renderedMatch2.getStart();
      return length2 - length1;
    }
  }
);
  ArrayList<RenderedMatch> out=new ArrayList<RenderedMatch>(renderedMatches.size());
  for (  RenderedMatch match : renderedMatches) {
    boolean addMatch=true;
    Iterator<RenderedMatch> superIter=out.iterator();
    while (superIter.hasNext()) {
      RenderedMatch supermatch=superIter.next();
      if (match.getStart() >= supermatch.getStart() && match.getEnd() <= supermatch.getEnd()) {
        addMatch=false;
        break;
      }
 else       if ((match.getStart() > supermatch.getStart() && match.getStart() < supermatch.getEnd()) || (match.getEnd() > supermatch.getStart() && match.getEnd() < supermatch.getEnd())) {
        addMatch=false;
        superIter.remove();
        break;
      }
    }
    if (addMatch) {
      out.add(match);
    }
  }
  return out;
}
Program: 189139
Project: 189139
Buggy source:
@Override public int compare(RenderedMatch renderedMatch,RenderedMatch renderedMatch2){
  int length1=renderedMatch.getEnd() - renderedMatch.getStart();
  int length2=renderedMatch2.getEnd() - renderedMatch.getEnd();
  return length2 - length1;
}

Fixed version (ground truth):
@Override public int compare(RenderedMatch renderedMatch,RenderedMatch renderedMatch2){
  int length1=renderedMatch.getEnd() - renderedMatch.getStart();
  int length2=renderedMatch2.getEnd() - renderedMatch2.getStart();
  return length2 - length1;
}