nus-yam/ex-repair huggingface dataset:
Program: 17715
Project: 17715
Buggy source:
synchronized void runHooks(ChannelFuture fut){
  future=fut;
  if (!hooks.isEmpty()) {
    Channel channel=fut.channel();
    channel.closeFuture().addListener(s);
    Application application=applicationProvider.get();
    List<ServerLifecycleHook> local=new ArrayList<>(hooks);
    hooks.clear();
    for (    ServerLifecycleHook hook : local) {
      try {
        hook.onStartup(application,channel);
        forShutdown.add(hook);
      }
 catch (      Exception ex) {
        startupExceptionsThrown=true;
        System.err.println("String_Node_Str" + hook);
        ctrl.get().internalOnError(ex);
      }
    }
  }
}

Fixed version (ground truth):
synchronized void runHooks(ChannelFuture fut){
  future=fut;
  if (!hooks.isEmpty()) {
    Channel channel=fut.channel();
    channel.closeFuture().addListener(s);
    Application application=applicationProvider.get();
    List<ServerLifecycleHook> local=new ArrayList<>(hooks);
    hooks.clear();
    for (    ServerLifecycleHook hook : local) {
      try {
        hook.onStartup(application,channel);
        forShutdown.add(hook);
      }
 catch (      Exception ex) {
        startupExceptionsThrown=true;
        ctrl.get().internalOnError(ex);
      }
    }
  }
}
Program: 17716
Project: 17716
Buggy source:
@Override protected void onStartup(Application application,Channel channel) throws Exception {
  HOOK_RAN.incrementAndGet();
}

Fixed version (ground truth):
@Override protected void onStartup(Application application,Channel channel) throws Exception {
  int amt=HOOK_RAN.incrementAndGet();
}
Program: 17717
Project: 17717
Buggy source:
@Test public void testDateHeaderHandling(TestHarness harn) throws Throwable {
  assertEquals("String_Node_Str",1,HOOK_RAN.get());
  ZonedDateTime when=harn.get("String_Node_Str").go().assertHasHeader(Headers.LAST_MODIFIED).assertContent("String_Node_Str").getHeader(Headers.LAST_MODIFIED);
  assertEquals(when.toInstant(),WHEN.toInstant());
  harn.get("String_Node_Str").addHeader(Headers.IF_MODIFIED_SINCE,when).go().assertStatus(NOT_MODIFIED);
  harn.get("String_Node_Str").addHeader(Headers.IF_MODIFIED_SINCE,WHEN).go().assertStatus(NOT_MODIFIED);
  harn.get("String_Node_Str").addHeader(Headers.IF_MODIFIED_SINCE,WHEN.plus(Duration.ofHours(1))).go().assertStatus(NOT_MODIFIED);
  harn.get("String_Node_Str").addHeader(Headers.IF_MODIFIED_SINCE,WHEN.minus(Duration.ofHours(1))).go().assertStatus(OK);
}

Fixed version (ground truth):
@Test public void testDateHeaderHandling(TestHarness harn) throws Throwable {
  ZonedDateTime when=harn.get("String_Node_Str").go().assertHasHeader(Headers.LAST_MODIFIED).assertContent("String_Node_Str").getHeader(Headers.LAST_MODIFIED);
  assertEquals(when.toInstant(),WHEN.toInstant());
  harn.get("String_Node_Str").addHeader(Headers.IF_MODIFIED_SINCE,when).go().assertStatus(NOT_MODIFIED);
  harn.get("String_Node_Str").addHeader(Headers.IF_MODIFIED_SINCE,WHEN).go().assertStatus(NOT_MODIFIED);
  harn.get("String_Node_Str").addHeader(Headers.IF_MODIFIED_SINCE,WHEN.plus(Duration.ofHours(1))).go().assertStatus(NOT_MODIFIED);
  harn.get("String_Node_Str").addHeader(Headers.IF_MODIFIED_SINCE,WHEN.minus(Duration.ofHours(1))).go().assertStatus(OK);
  assertTrue("String_Node_Str",HOOK_RAN.get() > 0);
}
Program: 17718
Project: 17718
Buggy source:
@Override public <T>ChannelPromise broadcast(T obj,Channel origin) throws Exception {
  ChannelPromise p=origin.newPromise();
  Set<Channel> all=reg.allChannels();
  all.remove(origin);
  if (all.isEmpty()) {
    return p.setSuccess();
  }
  ByteBuf buf=alloc.buffer();
  marshallers.write(obj,buf);
  final BinaryWebSocketFrame frame=new BinaryWebSocketFrame(buf);
  threadPool.submit(() -> {
    new CHF(all.iterator(),frame,p).operationComplete(null);
  }
);
  return p;
}

Fixed version (ground truth):
@Override public <T>ChannelPromise broadcast(T obj,Channel origin) throws Exception {
  ChannelPromise p=origin.newPromise();
  Set<Channel> all=new HashSet<>(reg.allChannels());
  all.remove(origin);
  if (all.isEmpty()) {
    return p.setSuccess();
  }
  ByteBuf buf=alloc.buffer();
  marshallers.write(obj,buf);
  final BinaryWebSocketFrame frame=new BinaryWebSocketFrame(buf);
  threadPool.submit(() -> {
    new CHF(all.iterator(),frame,p).operationComplete(null);
  }
);
  return p;
}
Program: 17719
Project: 17719
Buggy source:
@Override public void decoratePage(Page page,HttpEvent evt,String path,Response response,boolean chunked){
  if (file.lastModified() != lastModified) {
    try {
      load();
    }
 catch (    Exception ex) {
      Exceptions.printStackTrace(ex);
    }
  }
  ResponseHeaders h=page.getResponseHeaders();
  String ua=evt.getHeader("String_Node_Str");
  if (ua != null && !ua.contains("String_Node_Str")) {
    page.getResponseHeaders().addVaryHeader(Headers.ACCEPT_ENCODING);
  }
  page.getResponseHeaders().addCacheControl(CacheControlTypes.Public);
  page.getResponseHeaders().addCacheControl(CacheControlTypes.max_age,maxAge);
  page.getResponseHeaders().addCacheControl(CacheControlTypes.must_revalidate);
  h.setLastModified(new DateTime(lastModified));
  h.setEtag(hash);
  MediaType type=getContentType();
  if (type == null && debug) {
    System.err.println("String_Node_Str" + name);
  }
  if (type != null) {
    h.setContentType(type);
  }
  if (internalGzip) {
    response.add(Headers.stringHeader("String_Node_Str"),"String_Node_Str");
  }
  if (chunked) {
    response.add(Headers.stringHeader("String_Node_Str"),"String_Node_Str");
  }
  if (isGzip(evt)) {
    page.getResponseHeaders().setContentEncoding("String_Node_Str");
    response.add(Headers.CONTENT_ENCODING,"String_Node_Str");
    if (!chunked) {
      response.add(Headers.CONTENT_LENGTH,(long)compressed.readableBytes());
    }
  }
 else {
    if (!chunked) {
      response.add(Headers.CONTENT_LENGTH,(long)bytes.readableBytes());
    }
  }
  response.setChunked(chunked);
}

Fixed version (ground truth):
@Override public void decoratePage(Page page,HttpEvent evt,String path,Response response,boolean chunked){
  if (file.lastModified() != lastModified) {
    try {
      load();
    }
 catch (    Exception ex) {
      Exceptions.printStackTrace(ex);
    }
  }
  ResponseHeaders h=page.getResponseHeaders();
  String ua=evt.getHeader("String_Node_Str");
  if (ua != null && !ua.contains("String_Node_Str")) {
    page.getResponseHeaders().addVaryHeader(Headers.ACCEPT_ENCODING);
  }
  h.addCacheControl(CacheControlTypes.Public);
  h.addCacheControl(CacheControlTypes.max_age,maxAge);
  h.addCacheControl(CacheControlTypes.must_revalidate);
  h.setLastModified(new DateTime(lastModified));
  h.setEtag(hash);
  MediaType type=getContentType();
  if (type == null && debug) {
    System.err.println("String_Node_Str" + name);
  }
  if (type != null) {
    h.setContentType(type);
  }
  if (internalGzip) {
    response.add(Headers.stringHeader("String_Node_Str"),"String_Node_Str");
  }
  if (chunked) {
    response.add(Headers.stringHeader("String_Node_Str"),"String_Node_Str");
  }
  if (isGzip(evt)) {
    page.getResponseHeaders().setContentEncoding("String_Node_Str");
    response.add(Headers.CONTENT_ENCODING,"String_Node_Str");
    if (!chunked) {
      response.add(Headers.CONTENT_LENGTH,(long)compressed.readableBytes());
    }
  }
 else {
    if (!chunked) {
      response.add(Headers.CONTENT_LENGTH,(long)bytes.readableBytes());
    }
  }
  response.setChunked(chunked);
}
Program: 17720
Project: 17720
Buggy source:
private void scan(File dir,String path,List<String> result){
  for (  File f : dir.listFiles()) {
    if (f.isFile() && f.canRead()) {
      result.add(path + (path.isEmpty() ? "String_Node_Str" : "String_Node_Str") + f.getName());
    }
 else     if (f.isDirectory()) {
      scan(f,path + (path.isEmpty() ? "String_Node_Str" : "String_Node_Str") + f.getName(),result);
    }
  }
}

Fixed version (ground truth):
private void scan(File dir,String path,List<String> result){
  if (dir == null) {
    return;
  }
  File[] files=dir.listFiles();
  if (files != null) {
    for (    File f : dir.listFiles()) {
      if (f.isFile() && f.canRead()) {
        result.add(path + (path.isEmpty() ? "String_Node_Str" : "String_Node_Str") + f.getName());
      }
 else       if (f.isDirectory()) {
        scan(f,path + (path.isEmpty() ? "String_Node_Str" : "String_Node_Str") + f.getName(),result);
      }
    }
  }
}
Program: 17721
Project: 17721
Buggy source:
private boolean check() throws Exception {
  Y y=new Y();
  ByteBuf test=allocator.buffer(bytes.readableBytes());
  try {
    y.decode(null,compressed,Collections.<Object>singletonList(test));
    compressed.resetReaderIndex();
    byte[] a=new byte[bytes.readableBytes()];
    bytes.readBytes(a);
    byte[] b=new byte[test.readableBytes()];
    test.readBytes(b);
    if (!Arrays.equals(a,b)) {
      throw new IllegalStateException("String_Node_Str" + a.length + "String_Node_Str"+ b.length+ "String_Node_Str"+ new String(a)+ "String_Node_Str"+ new String(b));
    }
    bytes.resetReaderIndex();
  }
  finally {
    test.release();
  }
  return true;
}

Fixed version (ground truth):
private boolean check() throws Exception {
  SanityCheckDecoder y=new SanityCheckDecoder();
  ByteBuf test=allocator.buffer(bytes.readableBytes());
  try {
    y.decode(null,compressed,Collections.<Object>singletonList(test));
    compressed.resetReaderIndex();
    byte[] a=new byte[bytes.readableBytes()];
    bytes.readBytes(a);
    byte[] b=new byte[test.readableBytes()];
    test.readBytes(b);
    if (!Arrays.equals(a,b)) {
      throw new IllegalStateException("String_Node_Str" + a.length + "String_Node_Str"+ b.length+ "String_Node_Str"+ new String(a)+ "String_Node_Str"+ new String(b));
    }
    bytes.resetReaderIndex();
  }
  finally {
    test.release();
  }
  return true;
}
Program: 17722
Project: 17722
Buggy source:
@Inject ResourceNameMatcher(HttpEvent evt,StaticResources res,Settings settings,ExpiresPolicy policy,Page page) throws UnsupportedEncodingException {
  String base=settings.getString(SETTINGS_KEY_STATIC_RESOURCES_BASE_URL_PATH);
  String path=evt.getPath().toString();
  if (base != null && !base.isEmpty()) {
    Pattern p=Pattern.compile(base);
    Matcher m=p.matcher(path);
    if (m.find()) {
      path=m.group(1);
    }
  }
  path=URLDecoder.decode(path,"String_Node_Str");
  for (  String pat : res.getPatterns()) {
    if (path.equals(pat)) {
      Resource r=res.get(path);
      if (r == null) {
        reject();
        return;
      }
 else {
        r.decoratePage(page,evt,path,response(),chunked);
        MediaType mimeType=r.getContentType();
        if (mimeType != null) {
          DateTime dt=policy.get(mimeType,Path.parse(path));
          if (dt != null) {
            add(Headers.EXPIRES,dt);
          }
        }
        next(r);
        return;
      }
    }
  }
  reject();
}

Fixed version (ground truth):
@Inject ResourceNameMatcher(HttpEvent evt,StaticResources res,Settings settings,ExpiresPolicy policy,Page page) throws UnsupportedEncodingException {
  String base=settings.getString(SETTINGS_KEY_STATIC_RESOURCES_BASE_URL_PATH);
  String path=evt.getPath().toString();
  if (base != null && !base.isEmpty()) {
    Pattern p=Pattern.compile(base);
    Matcher m=p.matcher(path);
    if (m.find()) {
      path=m.group(1);
    }
  }
  path=URLDecoder.decode(path,"String_Node_Str");
  String[] patterns=res.getPatterns();
  if (patterns != null) {
    for (    String pat : res.getPatterns()) {
      if (path.equals(pat)) {
        Resource r=res.get(path);
        if (r == null) {
          reject();
          return;
        }
 else {
          r.decoratePage(page,evt,path,response(),chunked);
          MediaType mimeType=r.getContentType();
          if (mimeType != null) {
            DateTime dt=policy.get(mimeType,Path.parse(path));
            if (dt != null) {
              add(Headers.EXPIRES,dt);
            }
          }
          next(r);
          return;
        }
      }
    }
  }
 else {
    Resource r=res.get(path);
    if (r != null) {
      r.decoratePage(page,evt,path,response(),chunked);
      MediaType mimeType=r.getContentType();
      if (mimeType != null) {
        DateTime dt=policy.get(mimeType,Path.parse(path));
        if (dt != null) {
          add(Headers.EXPIRES,dt);
        }
      }
      next(r);
      return;
    }
  }
  reject();
}
Program: 17723
Project: 17723
Buggy source:
@Inject public ResourcesPage(ActeurFactory af,StaticResources r,Settings settings){
  add(af.matchMethods(Method.GET,Method.HEAD));
  String base=settings.getString(SETTINGS_KEY_STATIC_RESOURCES_BASE_URL_PATH);
  if (base != null) {
    add(af.matchPath(base));
  }
  add(ResourceNameMatcher.class);
  add(af.sendNotModifiedIfIfModifiedSinceHeaderMatches());
  add(af.sendNotModifiedIfETagHeaderMatches());
  add(BytesWriter.class);
}

Fixed version (ground truth):
@Inject public ResourcesPage(ActeurFactory af,StaticResources r,Settings settings){
  add(af.matchMethods(Method.GET,Method.HEAD));
  String base=settings.getString(SETTINGS_KEY_STATIC_RESOURCES_BASE_URL_PATH);
  if (base != null && !base.isEmpty()) {
    add(af.matchPath(base));
  }
  add(ResourceNameMatcher.class);
  add(af.sendNotModifiedIfIfModifiedSinceHeaderMatches());
  add(af.sendNotModifiedIfETagHeaderMatches());
  add(BytesWriter.class);
}
Program: 17724
Project: 17724
Buggy source:
Resource get(String path);

Fixed version (ground truth):
/** 
 * Get a resource that should be served.
 * @param path The path from the base dir to the file
 * @return A resource or null
 */
Resource get(String path);
Program: 17726
Project: 17726
Buggy source:
@Override public String toString(Object msg){
  if (msg instanceof String) {
    return msg.toString();
  }
  try {
    return codec.writeValueAsString(codec);
  }
 catch (  IOException ex) {
    ctrl.internalOnError(ex);
    return null;
  }
}

Fixed version (ground truth):
@Override public String toString(Object msg){
  if (msg instanceof String) {
    return msg.toString();
  }
  try {
    return codec.writeValueAsString(msg);
  }
 catch (  IOException ex) {
    ctrl.internalOnError(ex);
    return null;
  }
}
Program: 17727
Project: 17727
Buggy source:
public Message(String eventType,long id,Object message){
  this.eventType=eventType;
  this.id=id;
  this.message=message;
}

Fixed version (ground truth):
public Message(EventChannelName channelName,String eventType,long id,Object message){
  this.channelName=channelName;
  this.eventType=eventType;
  this.id=id;
  this.message=message;
}
Program: 17728
Project: 17728
Buggy source:
/** 
 * Publish an event
 * @param message The message. If non-string, it will be encoded as JSON bydefault
 * @return this
 */
public EventSink publish(Object message){
  if (shutdown || channels.isEmpty()) {
    return this;
  }
  Checks.notNull("String_Node_Str",message);
  Message msg=new Message(count.getAndIncrement(),message);
  messages.offer(msg);
  return this;
}

Fixed version (ground truth):
/** 
 * Publish an event to a named channel
 * @param name The name of the subchannel
 * @param message The message. If non-string, it will be encoded as JSON bydefault
 * @return this
 */
public EventSink publish(EventChannelName name,Object message){
  Checks.notNull("String_Node_Str",message);
  if (shutdown || channels.isEmpty()) {
    return this;
  }
  for (  EventChannelName n : channelsForName.keySet()) {
    if (name.equals(n)) {
      name=n;
      break;
    }
  }
  long id=name == null ? count.getAndIncrement() : name.nextId();
  Message msg=new Message(name,id,message);
  messages.offer(msg);
  return this;
}
Program: 17729
Project: 17729
Buggy source:
/** 
 * Register a channel which will receive events from this event sink.
 * @param channel A channel
 * @return this
 */
public EventSink register(Channel channel){
  if (!shutdown && channel.isOpen()) {
    channels.add(channel);
  }
  return this;
}

Fixed version (ground truth):
public synchronized EventSink register(EventChannelName name,Channel channel){
  if (!shutdown && channel.isOpen()) {
    channels.add(channel);
    List<Channel> chlls=channelsForName.get(name);
    if (chlls == null) {
      chlls=Lists.newCopyOnWriteArrayList(Arrays.asList(channel));
      channelsForName.put(name,chlls);
    }
 else {
      chlls.add(channel);
    }
    channel.closeFuture().addListener(new RemoveListener(name));
    register(channel);
  }
  return this;
}
Program: 17730
Project: 17730
Buggy source:
@Inject public SseActeur(EventSink sink){
  add(Headers.CONTENT_TYPE,TYPE);
  add(Headers.CACHE_CONTROL,CacheControl.PRIVATE_NO_CACHE_NO_STORE);
  add(Headers.CONNECTION,Connection.keep_alive);
  setState(new RespondWith(OK));
  setResponseBodyWriter(new L(sink));
  setChunked(true);
}

Fixed version (ground truth):
@Inject public SseActeur(EventSink sink,Provider<EventChannelName> name){
  add(Headers.CONTENT_TYPE,TYPE);
  add(Headers.CACHE_CONTROL,CacheControl.PRIVATE_NO_CACHE_NO_STORE);
  add(Headers.CONNECTION,Connection.keep_alive);
  setState(new RespondWith(OK));
  setResponseBodyWriter(new L(sink,name.get()));
  setChunked(true);
}
Program: 17731
Project: 17731
Buggy source:
public L(EventSink sink){
  this.sink=sink;
}

Fixed version (ground truth):
public L(EventSink sink,EventChannelName name){
  this.sink=sink;
  this.name=name;
}
Program: 17732
Project: 17732
Buggy source:
@Override public void operationComplete(ChannelFuture future) throws Exception {
  sink.register(future.channel());
}

Fixed version (ground truth):
@Override public void operationComplete(ChannelFuture future) throws Exception {
  if (name == null) {
    sink.register(future.channel());
  }
 else {
    sink.register(name,future.channel());
  }
}
Program: 17733
Project: 17733
Buggy source:
public Set<Class<?>> implicitBindings(){
  Set<Class<?>> types=new LinkedHashSet<>();
  for (  Entry e : entries()) {
    types.addAll(e.bindings);
  }
  ClassLoader cl=type.getClassLoader();
  try {
    for (    URL url : CollectionUtils.toIterable(cl.getResources("String_Node_Str"))) {
      try (final InputStream in=url.openStream()){
        String[] lines=Streams.readString(in,"String_Node_Str").split("String_Node_Str");
        for (        String line : lines) {
          if (line.isEmpty() || line.startsWith("String_Node_Str")) {
            continue;
          }
          System.err.println("String_Node_Str" + line + "String_Node_Str");
          types.add(cl.loadClass(line));
        }
      }
 catch (      ClassNotFoundException ex) {
        return Exceptions.chuck(ex);
      }
    }
  }
 catch (  IOException ex) {
    return Exceptions.chuck(ex);
  }
  return types;
}

Fixed version (ground truth):
public Set<Class<?>> implicitBindings(){
  Set<Class<?>> types=new LinkedHashSet<>();
  for (  Entry e : entries()) {
    types.addAll(e.bindings);
  }
  ClassLoader cl=type.getClassLoader();
  try {
    for (    URL url : CollectionUtils.toIterable(cl.getResources("String_Node_Str"))) {
      try (final InputStream in=url.openStream()){
        String[] lines=Streams.readString(in,"String_Node_Str").split("String_Node_Str");
        for (        String line : lines) {
          line=line.trim();
          if (line.isEmpty() || line.startsWith("String_Node_Str")) {
            continue;
          }
          System.err.println("String_Node_Str" + line + "String_Node_Str");
          types.add(cl.loadClass(line));
        }
      }
 catch (      ClassNotFoundException ex) {
        return Exceptions.chuck(ex);
      }
    }
  }
 catch (  IOException ex) {
    return Exceptions.chuck(ex);
  }
  return types;
}
Program: 17734
Project: 17734
Buggy source:
public final Closables add(Runnable run){
  Checks.notNull("String_Node_Str",run);
  add(new RunnableWrapper(run));
  return this;
}

Fixed version (ground truth):
public final Closables add(Runnable run){
  Checks.notNull("String_Node_Str",run);
  for (  AutoCloseable clos : closeables) {
    if (clos instanceof RunnableWrapper) {
      RunnableWrapper w=(RunnableWrapper)clos;
      if (w.run == w.run) {
        return this;
      }
    }
  }
  add(new RunnableWrapper(run));
  return this;
}
Program: 17735
Project: 17735
Buggy source:
Closables(Channel channel,Application application){
  channel.closeFuture().addListener(closeListener);
  this.application=application;
}

Fixed version (ground truth):
Closables(Channel channel,ApplicationControl application){
  channel.closeFuture().addListener(closeListener);
  this.application=application;
}
Program: 17737
Project: 17737
Buggy source:
/** 
 * Returns a CountDownLatch which can be used in tests to wait until a request has been fully processed
 * @param id The request unique id
 * @param event The event - the request itself
 * @param channel The channel
 * @return A latch which will count down when we're done
 */
@Override public final CountDownLatch onEvent(final RequestID id,final Event<?> event,final Channel channel){
  Iterator<Page> it=application.iterator();
  CountDownLatch latch=new CountDownLatch(1);
  Closables closables=new Closables(channel,application);
  PageRunner pageRunner=new PageRunner(application,it,latch,id,event,channel,scheduler,closables);
  application.getWorkerThreadPool().submit(pageRunner);
  return latch;
}

Fixed version (ground truth):
/** 
 * Returns a CountDownLatch which can be used in tests to wait until a request has been fully processed.  Note that the latch will be called when the <i>headers have been flushed</i> - it is entirely possible that a listener has been attached which will write a body after that. Add a close listener to the channel to detect that the channel has been completely written to.
 * @param id The request unique id
 * @param event The event - the request itself
 * @param channel The channel
 * @return A latch which will count down when we're done
 */
@Override public final CountDownLatch onEvent(final RequestID id,final Event<?> event,final Channel channel){
  Iterator<Page> it=application.iterator();
  CountDownLatch latch=new CountDownLatch(1);
  Closables closables=new Closables(channel,application.control());
  PageRunner pageRunner=new PageRunner(application,it,latch,id,event,channel,scheduler,closables);
  application.getWorkerThreadPool().submit(pageRunner);
  return latch;
}
Program: 17738
Project: 17738
Buggy source:
@Override public void operationComplete(final ChannelFuture future) throws Exception {
  Callable<Void> c=new Callable<Void>(){
    @Override public Void call() throws Exception {
      inOperationComplete=true;
      try {
        ResponseWriterListener.this.future=future;
        ResponseWriter.Status status=writer.write(evt,ResponseWriterListener.this,callCount++);
        if (status.isCallback()) {
          ResponseWriterListener.this.future=ResponseWriterListener.this.future.addListener(ResponseWriterListener.this);
        }
 else         if (status == Status.DONE) {
          if (chunked) {
            ResponseWriterListener.this.future=ResponseWriterListener.this.future.channel().writeAndFlush(LastHttpContent.EMPTY_LAST_CONTENT);
          }
          if (shouldClose) {
            ResponseWriterListener.this.future=ResponseWriterListener.this.future.addListener(CLOSE);
          }
        }
      }
  finally {
        inOperationComplete=false;
      }
      return null;
    }
  }
;
  if (!inOperationComplete) {
    c.call();
  }
 else {
    svc.submit(c);
  }
}

Fixed version (ground truth):
@Override public void operationComplete(final ChannelFuture future) throws Exception {
  try {
    if (entryCount > 0) {
      svc.submit(new Runnable(){
        @Override public void run(){
          try {
            operationComplete(future);
          }
 catch (          Exception ex) {
            Exceptions.chuck(ex);
          }
        }
      }
);
      return;
    }
    entryCount++;
    Callable<Void> c=new Callable<Void>(){
      @Override public Void call() throws Exception {
        inOperationComplete=true;
        try {
          ResponseWriterListener.this.future=future;
          ResponseWriter.Status status=writer.write(evt,ResponseWriterListener.this,callCount++);
          if (status.isCallback()) {
            ResponseWriterListener.this.future=ResponseWriterListener.this.future.addListener(ResponseWriterListener.this);
          }
 else           if (status == Status.DONE) {
            if (chunked) {
              ResponseWriterListener.this.future=ResponseWriterListener.this.future.channel().writeAndFlush(LastHttpContent.EMPTY_LAST_CONTENT);
            }
            if (shouldClose) {
              ResponseWriterListener.this.future=ResponseWriterListener.this.future.addListener(CLOSE);
            }
          }
        }
  finally {
          inOperationComplete=false;
        }
        return null;
      }
    }
;
    if (!inOperationComplete) {
      c.call();
    }
 else {
      svc.submit(c);
    }
  }
  finally {
    entryCount--;
  }
}
Program: 17739
Project: 17739
Buggy source:
@Override public State getState(){
  Page page=deps.getInstance(Page.class);
  page.getReponseHeaders().setETagProvider(this);
  CheckIfNoneMatchHeader h=deps.getInstance(CheckIfNoneMatchHeader.class);
  State result=h.getState();
  getResponse().merge(h.getResponse());
  return result;
}

Fixed version (ground truth):
@Override public State getState(){
  return getDelegate().getState();
}
Program: 17740
Project: 17740
Buggy source:
/** 
 * Get the set of page instances, constructing them dynamically. Note that this should be called inside the application scope, with any objects which need to be available for injection available in the scope.
 * @return An iterator
 */
@Override public Iterator<Page> iterator(){
  final Iterator<Object> it=pages.iterator();
  return new Iterator<Page>(){
    @Override public boolean hasNext(){
      return it.hasNext();
    }
    @Override public Page next(){
      try {
        Object o=it.next();
        Page result;
        if (o instanceof Class<?>) {
          Class<? extends Page> clazz=(Class<? extends Page>)o;
          result=deps.getInstance(clazz);
        }
 else {
          result=Page.class.cast(o);
        }
        result.setApplication(Application.this);
        return result;
      }
 catch (      Exception e) {
        Application.this.internalOnError(e);
        return Exceptions.chuck(e);
      }
    }
    @Override public void remove(){
      throw new UnsupportedOperationException("String_Node_Str");
    }
  }
;
}

Fixed version (ground truth):
/** 
 * Get the set of page instances, constructing them dynamically. Note that this should be called inside the application scope, with any objects which need to be available for injection available in the scope.
 * @return An iterator
 */
@Override public Iterator<Page> iterator(){
  return new InstantiatingIterators(deps).iterable(pages,Page.class).iterator();
}
Program: 17741
Project: 17741
Buggy source:
protected Acteurs getActeurs(ExecutorService exe,ReentrantScope scope){
  return new ActeursImpl(exe,scope,this,getApplication().getDependencies().getInstance(Settings.class));
}

Fixed version (ground truth):
Acteurs getActeurs(ExecutorService exe,ReentrantScope scope){
  return new ActeursImpl(exe,scope,this,getApplication().getDependencies().getInstance(Settings.class));
}
Program: 17742
Project: 17742
Buggy source:
public synchronized ResponseHeaders getReponseHeaders(){
  return responseHeaders;
}

Fixed version (ground truth):
public final ResponseHeaders getReponseHeaders(){
  return responseHeaders;
}
Program: 17743
Project: 17743
Buggy source:
/** 
 * Do new model operations
 */
public BufferedImage expensiveModelOperations(BuildData bfnbd,boolean forMain,BTProgressMonitor monitor) throws IOException, AsynchExitRequestException {
  Dimension screenSize=(forMain && (headlessOracle_ == null)) ? Toolkit.getDefaultToolkit().getScreenSize() : new Dimension(600,800);
  BioFabricNetwork bfn=new BioFabricNetwork(bfnbd,pMan_,monitor);
  bfp_.installModel(bfn,monitor);
  int[] preZooms=bfp_.calcZoomSettings(screenSize);
  BufferedImage topImage=null;
  if (headlessOracle_ == null) {
    if (forMain) {
      BufferBuilder bb=new BufferBuilder(null,100,bfp_,bfp_.getBucketRend(),bfp_.getBufImgStack());
      topImage=bb.buildBufs(preZooms,bfp_,25,monitor);
      bfp_.setBufBuilder(bb);
    }
 else {
      BufferBuilder bb=new BufferBuilder(bfp_,bfp_.getBucketRend(),bfp_.getBufImgStack());
      topImage=bb.buildOneBuf(preZooms);
      bfp_.setBufBuilder(null);
    }
  }
  return (topImage);
}

Fixed version (ground truth):
/** 
 * Do new model operations
 */
public BufferedImage expensiveModelOperations(BuildData bfnbd,boolean forMain,BTProgressMonitor monitor) throws IOException, AsynchExitRequestException {
  Dimension screenSize=(forMain && (headlessOracle_ == null)) ? Toolkit.getDefaultToolkit().getScreenSize() : new Dimension(600,800);
  BioFabricNetwork bfn=new BioFabricNetwork(bfnbd,pMan_,monitor);
  bfp_.installModel(bfn,monitor);
  int[] preZooms=bfp_.calcZoomSettings(screenSize);
  BufferedImage topImage=null;
  if (headlessOracle_ == null) {
    if (forMain) {
      BufferBuilder bb=new BufferBuilder(null,100,bfp_,bfp_.getBucketRend(),bfp_.getBufImgStack());
      topImage=bb.buildBufs(preZooms,bfp_,25,monitor);
      bfp_.setBufBuilder(bb);
    }
 else {
      BufferBuilder bb=new BufferBuilder(bfp_,bfp_.getBucketRend(),bfp_.getBufImgStack());
      topImage=bb.buildOneBuf();
      bfp_.setBufBuilder(null);
    }
  }
  return (topImage);
}
Program: 17744
Project: 17744
Buggy source:
/** 
 * Do new model operations
 */
public BufferedImage expensiveRecolorOperations(boolean forMain,BTProgressMonitor monitor) throws IOException, AsynchExitRequestException {
  Dimension screenSize=(forMain) ? Toolkit.getDefaultToolkit().getScreenSize() : new Dimension(800,400);
  screenSize.setSize((int)(screenSize.getWidth() * 0.8),(int)(screenSize.getHeight() * 0.4));
  colGen_.newColorModel();
  bfp_.changePaint(monitor);
  int[] preZooms=bfp_.getZoomController().getZoomIndices();
  BufferedImage topImage=null;
  if (forMain) {
    BufferBuilder bb=new BufferBuilder(null,100,bfp_,bfp_.getBucketRend(),bfp_.getBufImgStack());
    topImage=bb.buildBufs(preZooms,bfp_,24,monitor);
    bfp_.setBufBuilder(bb);
  }
 else {
    BufferBuilder bb=new BufferBuilder(bfp_,bfp_.getBucketRend(),bfp_.getBufImgStack());
    topImage=bb.buildOneBuf(preZooms);
    bfp_.setBufBuilder(null);
  }
  return (topImage);
}

Fixed version (ground truth):
/** 
 * Do new model operations
 */
public BufferedImage expensiveRecolorOperations(boolean forMain,BTProgressMonitor monitor) throws IOException, AsynchExitRequestException {
  Dimension screenSize=(forMain) ? Toolkit.getDefaultToolkit().getScreenSize() : new Dimension(800,400);
  screenSize.setSize((int)(screenSize.getWidth() * 0.8),(int)(screenSize.getHeight() * 0.4));
  colGen_.newColorModel();
  bfp_.changePaint(monitor);
  int[] zoomLevels=bfp_.getZoomController().getZoomLevels();
  BufferedImage topImage=null;
  if (forMain) {
    BufferBuilder bb=new BufferBuilder(null,100,bfp_,bfp_.getBucketRend(),bfp_.getBufImgStack());
    topImage=bb.buildBufs(zoomLevels,bfp_,24,monitor);
    bfp_.setBufBuilder(bb);
  }
 else {
    BufferBuilder bb=new BufferBuilder(bfp_,bfp_.getBucketRend(),bfp_.getBufImgStack());
    topImage=bb.buildOneBuf();
    bfp_.setBufBuilder(null);
  }
  return (topImage);
}
Program: 17746
Project: 17746
Buggy source:
/** 
 * Simple overview one-shot
 */
public BufferedImage buildOneBuf(int[] zooms){
  screenDim_=new Dimension();
  worldRect_=new Rectangle2D.Double();
  binRender_.dimsForBuf(screenDim_,worldRect_);
  Rectangle worldPiece=UiUtil.rectFromRect2D(worldRect_);
  BufferedImage bi=bis_.fetchImage(screenDim_.width,screenDim_.height,BufferedImage.TYPE_INT_RGB);
  double lpp=linksPerPix(screenDim_,worldPiece);
  BufBuildDrawer useDrawer=(lpp < TRANSITION_LPP_) ? drawRender_ : binRender_;
  useDrawer.drawForBuffer(bi,worldPiece,screenDim_,worldPiece,0,lpp);
  return (bi);
}

Fixed version (ground truth):
/** 
 * Simple overview one-shot
 */
public BufferedImage buildOneBuf(){
  screenDim_=new Dimension();
  worldRect_=new Rectangle2D.Double();
  binRender_.dimsForBuf(screenDim_,worldRect_);
  Rectangle worldPiece=UiUtil.rectFromRect2D(worldRect_);
  BufferedImage bi=bis_.fetchImage(screenDim_.width,screenDim_.height,BufferedImage.TYPE_INT_RGB);
  double lpp=linksPerPix(screenDim_,worldPiece);
  BufBuildDrawer useDrawer=(lpp < TRANSITION_LPP_) ? drawRender_ : binRender_;
  useDrawer.drawForBuffer(bi,worldPiece,screenDim_,worldPiece,0,lpp);
  return (bi);
}
Program: 17747
Project: 17747
Buggy source:
/** 
 * Display options have changed!
 */
public void optionsHaveChanged(boolean needRebuild,boolean needRecolor){
  if (!needRebuild && !needRecolor) {
    bfp_.repaint();
    return;
  }
  if (needRecolor && !needRebuild) {
    flf_.doRecolor(isForMain_);
  }
 else   if (needRebuild) {
    flf_.doDisplayOptionChange();
  }
  return;
}

Fixed version (ground truth):
/** 
 * Display options have changed!
 */
public void optionsHaveChanged(boolean needRebuild,boolean needRecolor){
  if (!needRebuild && !needRecolor) {
    bfp_.repaint();
    return;
  }
  if (!bfp_.hasAModel()) {
    return;
  }
  if (needRecolor && !needRebuild) {
    flf_.doRecolor(isForMain_);
  }
 else   if (needRebuild) {
    flf_.doDisplayOptionChange();
  }
  return;
}
Program: 17748
Project: 17748
Buggy source:
/** 
 * Do recolor
 */
public void doRecolor(boolean isForMain){
  File holdIt;
  try {
    holdIt=File.createTempFile("String_Node_Str","String_Node_Str");
    holdIt.deleteOnExit();
  }
 catch (  IOException ioex) {
    holdIt=null;
  }
  System.out.println("String_Node_Str");
  NetworkRecolor nb=new NetworkRecolor();
  nb.doNetworkRecolor(isForMain,holdIt);
  return;
}

Fixed version (ground truth):
/** 
 * Do recolor
 */
public void doRecolor(boolean isForMain){
  File holdIt;
  try {
    holdIt=File.createTempFile("String_Node_Str","String_Node_Str");
    holdIt.deleteOnExit();
  }
 catch (  IOException ioex) {
    holdIt=null;
  }
  NetworkRecolor nb=new NetworkRecolor();
  nb.doNetworkRecolor(isForMain,holdIt);
  return;
}
Program: 17749
Project: 17749
Buggy source:
/** 
 * Simple overview one-shot
 */
public BufferedImage buildOneBuf(int[] zooms){
  screenDim_=new Dimension();
  worldRect_=new Rectangle2D.Double();
  binRender_.dimsForBuf(screenDim_,worldRect_);
  Rectangle worldPiece=UiUtil.rectFromRect2D(worldRect_);
  UiUtil.fixMePrintout("String_Node_Str");
  UiUtil.fixMePrintout("String_Node_Str");
  System.out.println(bis_ + "String_Node_Str" + screenDim_);
  if (bis_ == null) {
    System.out.println(bis_ + "String_Node_Str" + screenDim_);
  }
  BufferedImage bi=bis_.fetchImage(screenDim_.width,screenDim_.height,BufferedImage.TYPE_INT_RGB);
  double lpp=linksPerPix(screenDim_,worldPiece);
  BufBuildDrawer useDrawer=(lpp < TRANSITION_LPP_) ? drawRender_ : binRender_;
  useDrawer.drawForBuffer(bi,worldPiece,screenDim_,worldPiece,0,lpp);
  return (bi);
}

Fixed version (ground truth):
/** 
 * Simple overview one-shot
 */
public BufferedImage buildOneBuf(int[] zooms){
  screenDim_=new Dimension();
  worldRect_=new Rectangle2D.Double();
  binRender_.dimsForBuf(screenDim_,worldRect_);
  Rectangle worldPiece=UiUtil.rectFromRect2D(worldRect_);
  BufferedImage bi=bis_.fetchImage(screenDim_.width,screenDim_.height,BufferedImage.TYPE_INT_RGB);
  double lpp=linksPerPix(screenDim_,worldPiece);
  BufBuildDrawer useDrawer=(lpp < TRANSITION_LPP_) ? drawRender_ : binRender_;
  useDrawer.drawForBuffer(bi,worldPiece,screenDim_,worldPiece,0,lpp);
  return (bi);
}
Program: 17750
Project: 17750
Buggy source:
/** 
 * Find link group intervals (same algorithm as Drain Zone calculator
 */
private AnnotationSet findLinkGroupIntervals(List<FabricLink> linkSet,BTProgressMonitor monitor) throws AsynchExitRequestException {
  LoopReporter lr=new LoopReporter(linkSet.size(),20,monitor,0,.25,"String_Node_Str");
  AnnotationSet annots=new AnnotationSet();
  int startIdx=0;
  String currentRel=linkSet.get(startIdx).getRelation();
  for (int index=0; index <= linkSet.size(); index++) {
    lr.report();
    if (index == linkSet.size()) {
      int endIdx=linkSet.size() - 1;
      AnnotationSet.Annot annot=new AnnotationSet.Annot(currentRel,startIdx,endIdx,0);
      annots.addAnnot(annot);
    }
 else     if (!linkSet.get(index).getRelation().equals(currentRel)) {
      int endIdx=index - 1;
      AnnotationSet.Annot annot=new AnnotationSet.Annot(currentRel,startIdx,endIdx,0);
      annots.addAnnot(annot);
      startIdx=index;
      currentRel=linkSet.get(index).getRelation();
    }
  }
  return (annots);
}

Fixed version (ground truth):
/** 
 * Find link group intervals (same algorithm as Drain Zone calculator
 */
private AnnotationSet findLinkGroupIntervals(List<FabricLink> linkSet,BTProgressMonitor monitor) throws AsynchExitRequestException {
  LoopReporter lr=new LoopReporter(linkSet.size(),20,monitor,0,.25,"String_Node_Str");
  AnnotationSet annots=new AnnotationSet();
  int startIdx=0;
  String currentRel=linkSet.get(startIdx).getRelation();
  for (int index=0; index <= linkSet.size(); index++) {
    lr.report();
    if (index == linkSet.size()) {
      int endIdx=linkSet.size() - 1;
      AnnotationSet.Annot annot=new AnnotationSet.Annot(currentRel,startIdx,endIdx,0,null);
      annots.addAnnot(annot);
    }
 else     if (!linkSet.get(index).getRelation().equals(currentRel)) {
      int endIdx=index - 1;
      AnnotationSet.Annot annot=new AnnotationSet.Annot(currentRel,startIdx,endIdx,0,null);
      annots.addAnnot(annot);
      startIdx=index;
      currentRel=linkSet.get(index).getRelation();
    }
  }
  return (annots);
}
Program: 17751
Project: 17751
Buggy source:
/** 
 * Install Layer Zero Node Annotations
 */
private void installAnnotations(BioFabricNetwork.NetworkAlignmentBuildData nabd,SortedMap<Integer,List<NID.WithName>> targetsGroup,List<NID.WithName> targets,NodeGroupMap grouper){
  Map<Integer,List<NID.WithName>> layerZeroAnnot=new TreeMap<Integer,List<NID.WithName>>();
  for (int i=0; i < grouper.numGroups(); i++) {
    List<NID.WithName> group=targetsGroup.get(i);
    if (group.isEmpty()) {
      continue;
    }
    layerZeroAnnot.put(i,new ArrayList<NID.WithName>());
    layerZeroAnnot.get(i).add(group.get(0));
    layerZeroAnnot.get(i).add(group.get(group.size() - 1));
  }
  AnnotationSet annots=new AnnotationSet();
  for (  Map.Entry<Integer,List<NID.WithName>> entry : layerZeroAnnot.entrySet()) {
    int nodeGroup=entry.getKey();
    String start=entry.getValue().get(0).toString(), end=entry.getValue().get(1).toString();
    int min=-1, max=-1;
    for (int i=0; i < targets.size(); i++) {
      if (start.equals(targets.get(i).toString())) {
        min=i;
      }
      if (end.equals(targets.get(i).toString())) {
        max=i;
      }
    }
    if (min > max || min < 0) {
      throw new IllegalStateException("String_Node_Str");
    }
    AnnotationSet.Annot annot=new AnnotationSet.Annot(grouper.getKey(nodeGroup),min,max,0);
    annots.addAnnot(annot);
  }
  nabd.setNodeAnnotations(annots);
  return;
}

Fixed version (ground truth):
/** 
 * Install Layer Zero Node Annotations
 */
private void installAnnotations(BioFabricNetwork.NetworkAlignmentBuildData nabd,SortedMap<Integer,List<NID.WithName>> targetsGroup,List<NID.WithName> targets,NodeGroupMap grouper){
  Map<Integer,List<NID.WithName>> layerZeroAnnot=new TreeMap<Integer,List<NID.WithName>>();
  for (int i=0; i < grouper.numGroups(); i++) {
    List<NID.WithName> group=targetsGroup.get(i);
    if (group.isEmpty()) {
      continue;
    }
    layerZeroAnnot.put(i,new ArrayList<NID.WithName>());
    layerZeroAnnot.get(i).add(group.get(0));
    layerZeroAnnot.get(i).add(group.get(group.size() - 1));
  }
  AnnotationSet annots=new AnnotationSet();
  for (  Map.Entry<Integer,List<NID.WithName>> entry : layerZeroAnnot.entrySet()) {
    int nodeGroup=entry.getKey();
    String start=entry.getValue().get(0).toString(), end=entry.getValue().get(1).toString();
    int min=-1, max=-1;
    for (int i=0; i < targets.size(); i++) {
      if (start.equals(targets.get(i).toString())) {
        min=i;
      }
      if (end.equals(targets.get(i).toString())) {
        max=i;
      }
    }
    if (min > max || min < 0) {
      throw new IllegalStateException("String_Node_Str");
    }
    AnnotationSet.Annot annot=new AnnotationSet.Annot(grouper.getKey(nodeGroup),min,max,0,null);
    annots.addAnnot(annot);
  }
  nabd.setNodeAnnotations(annots);
  return;
}
Program: 17753
Project: 17753
Buggy source:
/** 
 * existingOrd's link order will follow groupOrder's relation order.
 */
private void orderNetworkByGroups(SortedMap<Integer,FabricLink> existingOrd,List<String> groupOrder){
  Map<String,List<FabricLink>> groups=new TreeMap<String,List<FabricLink>>();
  for (  Map.Entry<Integer,FabricLink> entry : existingOrd.entrySet()) {
    FabricLink fl=entry.getValue();
    String rel=fl.getRelation();
    if (groups.get(rel) == null) {
      groups.put(rel,new ArrayList<FabricLink>());
    }
    groups.get(rel).add(fl);
  }
  int rowIdx=0;
  for (  String relation : groupOrder) {
    List<FabricLink> group=groups.get(relation);
    for (    FabricLink fl : group) {
      existingOrd.put(rowIdx,fl);
      rowIdx++;
    }
  }
  return;
}

Fixed version (ground truth):
/** 
 * existingOrd's link order will follow groupOrder's relation order.
 */
private void orderNetworkByGroups(SortedMap<Integer,FabricLink> existingOrd,List<String> groupOrder){
  Map<String,List<FabricLink>> groups=new TreeMap<String,List<FabricLink>>();
  for (  Map.Entry<Integer,FabricLink> entry : existingOrd.entrySet()) {
    FabricLink fl=entry.getValue();
    String rel=fl.getRelation();
    if (groups.get(rel) == null) {
      groups.put(rel,new ArrayList<FabricLink>());
    }
    groups.get(rel).add(fl);
  }
  int rowIdx=0;
  for (  String suffix : groupOrder) {
    for (    String fullRel : groups.keySet()) {
      if (bestSuffixMatch(fullRel,suffix,groupOrder)) {
        List<FabricLink> group=groups.get(fullRel);
        for (        FabricLink fl : group) {
          existingOrd.put(rowIdx,fl);
          rowIdx++;
        }
      }
    }
  }
  return;
}
Program: 17755
Project: 17755
Buggy source:
/** 
 * Answer if the given relation has the best suffix match the the given match, given all the options. Thus, "430" should match "30" instead of "0" if both are present.
 */
private boolean bestSuffixMatch(FabricLink nextLink,String relToMatch,List<String> allRels){
  if (relToMatch == null) {
    return (true);
  }
  String augR=nextLink.getAugRelation().relation;
  int topLen=0;
  String topRel=null;
  for (  String aRel : allRels) {
    int matchLen=aRel.length();
    if (matchLen < topLen) {
      continue;
    }
    int ioaRel=augR.indexOf(aRel);
    if ((ioaRel >= 0) && ((ioaRel == (augR.length() - matchLen)))) {
      if (topLen == matchLen) {
        throw new IllegalStateException();
      }
 else       if (topLen < matchLen) {
        topLen=matchLen;
        topRel=aRel;
      }
    }
  }
  if (topRel == null) {
    throw new IllegalStateException();
  }
  return (topRel.equals(relToMatch));
}

Fixed version (ground truth):
/** 
 * Answer if the given relation has the best suffix match with the given match, given all the options. Thus, "430" should match "30" instead of "0" if both are present.
 */
private boolean bestSuffixMatch(String augR,String relToMatch,List<String> allRels){
  if (relToMatch == null) {
    return (true);
  }
  int topLen=0;
  String topRel=null;
  for (  String aRel : allRels) {
    int matchLen=aRel.length();
    if (matchLen < topLen) {
      continue;
    }
    int ioaRel=augR.indexOf(aRel);
    if ((ioaRel >= 0) && ((ioaRel == (augR.length() - matchLen)))) {
      if (topLen == matchLen) {
        throw new IllegalStateException();
      }
 else       if (topLen < matchLen) {
        topLen=matchLen;
        topRel=aRel;
      }
    }
  }
  if (topRel == null) {
    throw new IllegalStateException();
  }
  return (topRel.equals(relToMatch));
}
Program: 17760
Project: 17760
Buggy source:
@Override public Object canonical(Object value){
  if (value == null)   return null;
  Class from=value.getClass();
  if (from == String.class)   return (int)(parse((String)value).getDateValue() / MILLIS_PER_DAY);
  if (Date.class.isAssignableFrom(from))   return (int)(((Date)value).getTime() / MILLIS_PER_DAY);
  if (from == Integer.class || from == int.class)   return value;
  if (from == Long.class || from == long.class)   return ((Long)value).intValue();
  throw new CascadingException("String_Node_Str" + Util.getTypeName(from));
}

Fixed version (ground truth):
@Override public Object canonical(Object value){
  if (value == null)   return null;
  Class from=value.getClass();
  if (from == String.class)   return (int)(parse((String)value).getDateValue() / MILLIS_PER_DAY);
  if (Date.class.isAssignableFrom(from))   return (int)Math.ceil((double)((Date)value).getTime() / MILLIS_PER_DAY);
  if (from == Integer.class || from == int.class)   return value;
  if (from == Long.class || from == long.class)   return ((Long)value).intValue();
  throw new CascadingException("String_Node_Str" + Util.getTypeName(from));
}
Program: 17761
Project: 17761
Buggy source:
static Branch resolveBranch(Stack stack,CascadingRelNode node,RexProgram program){
  final RelOptCluster cluster=node.getCluster();
  Split split=Split.of(program,cluster.getRexBuilder());
  CascadingRelNode child=(CascadingRelNode)((SingleRel)node).getChild();
  Branch branch=child.visitChild(stack);
  Pipe pipe=branch.current;
  for (  Pair<Op,RexProgram> pair : split.list) {
    pipe=addProgram(cluster,pipe,pair.left,pair.right);
  }
  pipe=stack.addDebug(node,pipe);
  return new Branch(pipe,branch);
}

Fixed version (ground truth):
static Branch resolveBranch(Stack stack,CascadingRelNode node,RexProgram program){
  final RelOptCluster cluster=node.getCluster();
  CascadingRelNode child=(CascadingRelNode)((SingleRel)node).getChild();
  Branch branch=child.visitChild(stack);
  Pipe pipe=branch.current;
  final List<String> names=getIncomingFieldNames(pipe);
  if (names != null && !names.equals(program.getInputRowType().getFieldNames()))   program=renameInputs(program,cluster.getRexBuilder(),names);
  Split split=Split.of(program,cluster.getRexBuilder());
  for (  Pair<Op,RexProgram> pair : split.list) {
    pipe=addProgram(cluster,pipe,pair.left,pair.right);
  }
  pipe=stack.addDebug(node,pipe);
  return new Branch(pipe,branch);
}
Program: 17762
Project: 17762
Buggy source:
private static Pipe addRename(RelOptCluster cluster,RexProgram program,Pipe pipe){
  if (!unique(program.getInputRowType().getFieldNames()))   throw new AssertionError();
  if (!unique(program.getOutputRowType().getFieldNames()))   throw new AssertionError();
  Fields incomingFields=createTypedFields(cluster,program.getInputRowType());
  Fields renameFields=createTypedFields(cluster,program.getOutputRowType());
  return new Rename(pipe,incomingFields,renameFields);
}

Fixed version (ground truth):
private static Pipe addRename(RelOptCluster cluster,RexProgram program,Pipe pipe){
  if (!unique(program.getInputRowType().getFieldNames()))   throw new AssertionError();
  if (!unique(program.getOutputRowType().getFieldNames()))   throw new AssertionError();
  final Permutation permutation=program.getPermutation();
  if (permutation == null)   throw new AssertionError();
  Fields incomingFields=createTypedFields(cluster,Mappings.apply(permutation.inverse(),program.getInputRowType().getFieldList()));
  Fields renameFields=createTypedFields(cluster,program.getOutputRowType());
  return new Rename(pipe,incomingFields,renameFields);
}