nus-yam/ex-repair huggingface dataset:
Program: 92445
Project: 92445
Buggy source:
public void stopAndWait() throws InterruptedException {
  final Thread currentThread=Thread.currentThread();
  int state;
  m_lock.lock();
  try {
    if (s_logger.isLoggable(Level.FINE)) {
      s_logger.log(Level.FINE,m_connector.getAddr() + "String_Node_Str" + m_state+ "String_Node_Str"+ m_stop);
    }
    if (m_state == STARTING_0) {
      if (m_stop)       return;
      m_stop=true;
      state=0;
    }
 else     if (m_state == STOPPED) {
      return;
    }
 else {
      if (m_callbackThread == currentThread) {
        m_stop=true;
        return;
      }
      if (m_stop) {
        while (m_state != STOPPED)         m_cond.wait();
        return;
      }
      m_stop=true;
      state=1;
    }
  }
  finally {
    m_lock.unlock();
  }
  if (state == 0) {
    if (s_logger.isLoggable(Level.FINE))     s_logger.log(Level.FINE,m_connector.getAddr().toString());
    assert(m_selectionKey == null);
    try {
      m_socketChannel.close();
    }
 catch (    IOException ex) {
      if (s_logger.isLoggable(Level.WARNING))       s_logger.warning(m_connector.getAddr() + "String_Node_Str" + ex+ "String_Node_Str");
    }
    m_socketChannel=null;
    m_collider.removeEmitterNoWait(m_connector);
  }
 else {
    m_collider.executeInSelectorThread(new Stopper());
    m_lock.lock();
    try {
      while (m_state != STOPPED)       m_cond.await();
    }
  finally {
      m_lock.unlock();
    }
  }
}

Fixed version (ground truth):
public void stopAndWait() throws InterruptedException {
  final Thread currentThread=Thread.currentThread();
  int state;
  m_lock.lock();
  try {
    if (s_logger.isLoggable(Level.FINE)) {
      s_logger.log(Level.FINE,m_connector.getAddr() + "String_Node_Str" + this.toString()+ "String_Node_Str"+ m_state+ "String_Node_Str"+ m_stop);
    }
    if (m_state == STARTING_0) {
      if (m_stop)       return;
      m_stop=true;
      state=0;
    }
 else     if (m_state == STOPPED) {
      return;
    }
 else {
      if (m_callbackThread == currentThread) {
        m_stop=true;
        return;
      }
      if (m_stop) {
        while (m_state != STOPPED)         m_cond.await();
        return;
      }
      m_stop=true;
      state=1;
    }
  }
  finally {
    m_lock.unlock();
  }
  if (state == 0) {
    if (s_logger.isLoggable(Level.FINE))     s_logger.log(Level.FINE,m_connector.getAddr() + "String_Node_Str" + this.toString());
    assert(m_selectionKey == null);
    try {
      m_socketChannel.close();
    }
 catch (    IOException ex) {
      if (s_logger.isLoggable(Level.WARNING))       s_logger.warning(m_connector.getAddr() + "String_Node_Str" + ex+ "String_Node_Str");
    }
    m_socketChannel=null;
    m_collider.removeEmitterNoWait(m_connector);
  }
 else {
    m_collider.executeInSelectorThread(new Stopper());
    m_lock.lock();
    try {
      while (m_state != STOPPED)       m_cond.await();
    }
  finally {
      m_lock.unlock();
    }
  }
}
Program: 92446
Project: 92446
Buggy source:
public int runInSelectorThread(){
  final int interestOps=m_selectionKey.interestOps();
  if ((interestOps & SelectionKey.OP_CONNECT) == 0) {
    boolean stopped;
    m_lock.lock();
    try {
      stopped=(m_state == STOPPED);
    }
  finally {
      m_lock.unlock();
    }
    if (!stopped) {
      m_waits++;
      m_collider.executeInSelectorThreadLater(this);
      return 0;
    }
  }
  m_lock.lock();
  try {
    assert(m_stop);
    m_state=STOPPED;
    m_cond.signalAll();
  }
  finally {
    m_lock.unlock();
  }
  if (s_logger.isLoggable(Level.FINE))   s_logger.log(Level.FINE,m_connector.getAddr() + "String_Node_Str" + m_waits+ "String_Node_Str");
  m_selectionKey.cancel();
  m_selectionKey=null;
  try {
    m_socketChannel.close();
  }
 catch (  IOException ex) {
    if (s_logger.isLoggable(Level.WARNING))     s_logger.log(Level.WARNING,m_connector.getAddr() + "String_Node_Str" + ex.toString()+ "String_Node_Str");
  }
  m_socketChannel=null;
  return 0;
}

Fixed version (ground truth):
public int runInSelectorThread(){
  if (s_logger.isLoggable(Level.FINE)) {
    s_logger.log(Level.FINE,m_connector.getAddr() + "String_Node_Str" + ConnectorImpl.this.toString()+ "String_Node_Str"+ m_waits);
  }
  final int interestOps=m_selectionKey.interestOps();
  if ((interestOps & SelectionKey.OP_CONNECT) == 0) {
    return 0;
  }
  m_lock.lock();
  try {
    assert(m_stop);
    m_state=STOPPED;
    m_cond.signalAll();
  }
  finally {
    m_lock.unlock();
  }
  if (s_logger.isLoggable(Level.FINE)) {
    s_logger.log(Level.FINE,m_connector.getAddr() + "String_Node_Str" + ConnectorImpl.this.toString()+ "String_Node_Str"+ m_waits+ "String_Node_Str");
  }
  m_selectionKey.cancel();
  m_selectionKey=null;
  try {
    m_socketChannel.close();
  }
 catch (  IOException ex) {
    if (s_logger.isLoggable(Level.WARNING)) {
      s_logger.log(Level.WARNING,m_connector.getAddr() + "String_Node_Str" + ConnectorImpl.this.toString()+ "String_Node_Str"+ ex.toString()+ "String_Node_Str");
    }
  }
  m_socketChannel=null;
  return 0;
}
Program: 92447
Project: 92447
Buggy source:
public void run(){
  try {
    ByteBuffer bb=ByteBuffer.allocateDirect(m_msg.capacity());
    SocketChannel socketChannel=SocketChannel.open(m_addr);
    socketChannel.socket().setTcpNoDelay(true);
    System.out.println("String_Node_Str" + socketChannel.getRemoteAddress() + "String_Node_Str");
    for (int idx=0; idx < 10; idx++) {
      socketChannel.write(m_msg);
      m_msg.flip();
      final int bytesReceived=socketChannel.read(bb);
      assert(bytesReceived == m_msg.capacity());
      bb.clear();
    }
    final long startTime=System.nanoTime();
    for (int c=m_messages; c > 0; c--) {
      socketChannel.write(m_msg);
      m_msg.flip();
      final int bytesReceived=socketChannel.read(bb);
      assert(bytesReceived == m_msg.capacity());
      bb.clear();
    }
    long endTime=System.nanoTime();
    socketChannel.close();
    int messages=(m_messages * 2);
    long tm=((endTime - startTime) / 1000);
    System.out.println(messages + "String_Node_Str" + Util.formatDelay(startTime,endTime)+ "String_Node_Str"+ (tm / messages)+ "String_Node_Str");
  }
 catch (  IOException ex) {
    ex.printStackTrace();
  }
}

Fixed version (ground truth):
public void run(){
  try {
    final ByteBuffer msg=m_msg.duplicate();
    final ByteBuffer buf=ByteBuffer.allocateDirect(m_msg.capacity());
    SocketChannel socketChannel=SocketChannel.open(m_addr);
    socketChannel.socket().setTcpNoDelay(true);
    System.out.println("String_Node_Str" + socketChannel.getRemoteAddress() + "String_Node_Str");
    for (int idx=0; idx < 10; idx++) {
      socketChannel.write(msg);
      msg.flip();
      final int bytesReceived=socketChannel.read(buf);
      assert(bytesReceived == m_msg.capacity());
      buf.clear();
    }
    final long startTime=System.nanoTime();
    for (int c=m_messages; c > 0; c--) {
      socketChannel.write(msg);
      msg.flip();
      final int bytesReceived=socketChannel.read(buf);
      assert(bytesReceived == m_msg.capacity());
      buf.clear();
    }
    long endTime=System.nanoTime();
    socketChannel.close();
    int messages=(m_messages * 2);
    long tm=((endTime - startTime) / 1000);
    System.out.println(messages + "String_Node_Str" + Util.formatDelay(startTime,endTime)+ "String_Node_Str"+ (tm / messages)+ "String_Node_Str");
  }
 catch (  IOException ex) {
    ex.printStackTrace();
  }
}
Program: 92453
Project: 92453
Buggy source:
public SessionImpl(SocketChannel socketChannel,ThreadPool threadPool,PerfCounter perfCounter){
  super(socketChannel);
  m_threadPool=threadPool;
  m_perfCounter=perfCounter;
  m_head=null;
  m_tail=new AtomicReference<ListItem>();
  m_iov=new ByteBuffer[32];
  m_writer=new Writer();
}

Fixed version (ground truth):
public SessionImpl(SocketChannel socketChannel,ThreadPool threadPool,PerfCounter perfCounter){
  super(socketChannel);
  m_threadPool=threadPool;
  m_perfCounter=perfCounter;
  m_head=null;
  m_tail=new AtomicReference<ListItem>();
  m_iov=new ByteBuffer[16];
  m_writer=new Writer();
}
Program: 92454
Project: 92454
Buggy source:
public void runInThreadPool(){
  final long startTime=System.nanoTime();
  int iovc=0;
  for (ListItem item=m_head; ; ) {
    m_iov[iovc]=item.buf;
    if (++iovc == m_iov.length)     break;
    item=item.next;
    if (item == null)     break;
  }
  try {
    m_socketChannel.write(m_iov,0,iovc);
  }
 catch (  IOException ex) {
    ex.printStackTrace();
  }
  for (int idx=0; idx < iovc; idx++) {
    m_iov[idx]=null;
    if (m_head.buf.remaining() > 0) {
      for (; idx < iovc; idx++)       m_iov[idx]=null;
      break;
    }
    ListItem next=m_head.next;
    if (next == null) {
      ListItem head=m_head;
      m_head=null;
      if (m_tail.compareAndSet(head,null)) {
        assert(idx == iovc - 1);
        break;
      }
      while (head.next == null)       ;
      next=head.next;
      head.next=null;
    }
 else     m_head.next=null;
    m_head=next;
  }
  if (m_head != null)   m_threadPool.execute(this);
  m_perfCounter.trace(startTime);
}

Fixed version (ground truth):
public void runInThreadPool(){
  final long startTime=System.nanoTime();
  int iovc=0;
  for (ListItem item=m_head; ; ) {
    m_iov[iovc]=item.buf;
    if (++iovc == m_iov.length)     break;
    item=item.next;
    if (item == null)     break;
  }
  try {
    m_socketChannel.write(m_iov,0,iovc);
  }
 catch (  IOException ex) {
    ex.printStackTrace();
  }
  iovc--;
  int idx=0;
  for (; idx < iovc; idx++) {
    m_iov[idx]=null;
    ListItem next=m_head.next;
    m_head.next=null;
    m_head=next;
  }
  m_iov[idx]=null;
  ListItem next=m_head.next;
  if (next == null) {
    ListItem head=m_head;
    m_head=null;
    if (!m_tail.compareAndSet(head,null)) {
      while (head.next == null)       ;
      m_head=head.next;
      head.next=null;
      m_threadPool.execute(this);
    }
  }
 else {
    m_head.next=null;
    m_head=next;
    m_threadPool.execute(this);
  }
  m_perfCounter.trace(startTime);
}
Program: 92455
Project: 92455
Buggy source:
public boolean closeConnection(){
  long state=m_state.get();
  long newState;
  for (; ; ) {
    if ((state & CLOSE) != 0)     return false;
    newState=state;
    newState|=CLOSE;
    if ((state & LENGTH_MASK) == 0) {
      assert((newState & SOCK_RC_MASK) != 0);
      newState-=SOCK_RC;
    }
    if (m_state.compareAndSet(state,newState))     break;
    state=m_state.get();
  }
  if (s_logger.isLoggable(Level.FINER)) {
    s_logger.finer(m_remoteSocketAddress.toString() + "String_Node_Str" + stateToString(state)+ "String_Node_Str"+ stateToString(newState));
  }
  if ((state & SOCK_RC_MASK) == 0)   m_collider.executeInSelectorThread(new SelectorDeregistrator());
 else   if ((state & STATE_MASK) == ST_RUNNING)   m_inputQueue.stop();
  return true;
}

Fixed version (ground truth):
public boolean closeConnection(){
  long state=m_state.get();
  long newState;
  for (; ; ) {
    if ((state & CLOSE) != 0)     return false;
    newState=(state | CLOSE);
    if (m_state.compareAndSet(state,newState))     break;
    state=m_state.get();
  }
  if (s_logger.isLoggable(Level.FINER)) {
    s_logger.finer(m_remoteSocketAddress.toString() + "String_Node_Str" + stateToString(state)+ "String_Node_Str"+ stateToString(newState));
  }
  if ((state & STATE_MASK) == ST_RUNNING)   m_inputQueue.stop();
  return true;
}
Program: 92456
Project: 92456
Buggy source:
public SessionImpl(ColliderImpl collider,SessionEmitter sessionEmitter,SocketChannel socketChannel,SelectionKey selectionKey,OutputQueue.DataBlockCache outputQueueDataBlockCache){
  Collider.Config colliderConfig=collider.getConfig();
  int sendBufSize=sessionEmitter.socketSendBufSize;
  if (sendBufSize == 0)   sendBufSize=colliderConfig.socketSendBufSize;
  if (sendBufSize == 0)   sendBufSize=(64 * 1024);
  int sendIovMax=(sendBufSize / outputQueueDataBlockCache.getBlockSize()) + 1;
  m_collider=collider;
  m_socketChannel=socketChannel;
  m_selectionKey=selectionKey;
  m_localSocketAddress=socketChannel.socket().getLocalSocketAddress();
  m_remoteSocketAddress=socketChannel.socket().getRemoteSocketAddress();
  m_selectorRegistrator=new SelectorRegistrator();
  m_state=new AtomicLong(ST_STARTING + SOCK_RC + SOCK_RC);
  m_outputQueue=new OutputQueue(outputQueueDataBlockCache);
  m_iov=new ByteBuffer[sendIovMax];
}

Fixed version (ground truth):
public SessionImpl(ColliderImpl collider,SessionEmitter sessionEmitter,SocketChannel socketChannel,SelectionKey selectionKey,OutputQueue.DataBlockCache outputQueueDataBlockCache){
  Collider.Config colliderConfig=collider.getConfig();
  int sendBufSize=sessionEmitter.socketSendBufSize;
  if (sendBufSize == 0)   sendBufSize=colliderConfig.socketSendBufSize;
  if (sendBufSize == 0)   sendBufSize=(64 * 1024);
  int sendIovMax=(sendBufSize / outputQueueDataBlockCache.getBlockSize()) + 1;
  m_collider=collider;
  m_socketChannel=socketChannel;
  m_selectionKey=selectionKey;
  m_localSocketAddress=socketChannel.socket().getLocalSocketAddress();
  m_remoteSocketAddress=socketChannel.socket().getRemoteSocketAddress();
  m_starter=new Starter();
  m_state=new AtomicLong(ST_STARTING + SOCK_RC + SOCK_RC);
  m_outputQueue=new OutputQueue(outputQueueDataBlockCache);
  m_iov=new ByteBuffer[sendIovMax];
}
Program: 92457
Project: 92457
Buggy source:
public final void initialize(InputQueue.DataBlockCache inputQueueDataBlockCache,Listener listener){
  m_selectionKey.attach(this);
  if (listener == null)   listener=new DummyListener();
  m_inputQueue=new InputQueue(m_collider,inputQueueDataBlockCache,this,m_socketChannel,m_selectionKey,listener);
  long state=m_state.get();
  long newState;
  for (; ; ) {
    assert((state & STATE_MASK) == ST_STARTING);
    assert((state & SOCK_RC_MASK) == (SOCK_RC + SOCK_RC));
    newState=state;
    if ((state & CLOSE) == 0) {
      newState&=~STATE_MASK;
      newState|=ST_RUNNING;
      if (m_state.compareAndSet(state,newState)) {
        m_inputQueue.start();
        break;
      }
    }
 else {
      newState-=SOCK_RC;
      if ((state & WAIT_WRITE) == 0)       newState-=SOCK_RC;
      if (m_state.compareAndSet(state,newState)) {
        listener.onConnectionClosed();
        if ((newState & SOCK_RC_MASK) == 0)         m_collider.executeInSelectorThread(new SelectorDeregistrator());
        break;
      }
    }
    state=m_state.get();
  }
  if (s_logger.isLoggable(Level.FINER)) {
    s_logger.finer(m_remoteSocketAddress.toString() + "String_Node_Str" + stateToString(state)+ "String_Node_Str"+ stateToString(newState));
  }
  if ((state & WAIT_WRITE) != 0)   m_collider.executeInSelectorThread(m_selectorRegistrator);
}

Fixed version (ground truth):
public final void initialize(InputQueue.DataBlockCache inputQueueDataBlockCache,Listener listener){
  m_selectionKey.attach(this);
  if (listener == null)   listener=new DummyListener();
  m_inputQueue=new InputQueue(m_collider,inputQueueDataBlockCache,this,m_socketChannel,m_selectionKey,listener);
  long state=m_state.get();
  long newState;
  for (; ; ) {
    assert((state & STATE_MASK) == ST_STARTING);
    newState=state;
    if ((state & CLOSE) == 0) {
      newState&=~STATE_MASK;
      newState|=ST_RUNNING;
      if (m_state.compareAndSet(state,newState)) {
        m_inputQueue.start();
        break;
      }
    }
 else {
      newState-=SOCK_RC;
      if ((state & LENGTH_MASK) == 0)       newState-=SOCK_RC;
      if (m_state.compareAndSet(state,newState)) {
        listener.onConnectionClosed();
        if ((newState & SOCK_RC_MASK) == 0)         m_collider.executeInSelectorThread(new SelectorDeregistrator());
        break;
      }
    }
    state=m_state.get();
  }
  if (s_logger.isLoggable(Level.FINE)) {
    s_logger.fine(m_remoteSocketAddress.toString() + "String_Node_Str" + stateToString(state)+ "String_Node_Str"+ stateToString(newState)+ "String_Node_Str");
  }
  if ((newState & WAIT_WRITE) != 0)   m_collider.executeInSelectorThread(m_starter);
}
Program: 92458
Project: 92458
Buggy source:
public void run(){
  if (s_logger.isLoggable(Level.FINE))   s_logger.fine(Thread.currentThread().getName() + "String_Node_Str");
  mainLoop:   for (; ; ) {
    taskLoop:     for (; ; ) {
      Task head=m_head.get();
      for (; ; ) {
        if (head == null) {
          if (m_stop)           break mainLoop;
 else           break taskLoop;
        }
        Task next=head.nextThreadPoolTask;
        if (m_head.compareAndSet(head,next)) {
          if (next == null)           m_tail.compareAndSet(head,null);
          break;
        }
        head=m_head.get();
      }
      head.nextThreadPoolTask=null;
      head.run();
    }
    m_idleThreads.incrementAndGet();
    try {
      m_sem.acquire();
    }
 catch (    InterruptedException ex) {
      if (s_logger.isLoggable(Level.WARNING))       s_logger.warning(Thread.currentThread().getName() + "String_Node_Str" + ex.toString());
      break;
    }
  }
  if (s_logger.isLoggable(Level.FINE))   s_logger.fine(Thread.currentThread().getName() + "String_Node_Str");
}

Fixed version (ground truth):
public void run(){
  if (s_logger.isLoggable(Level.FINE))   s_logger.fine(Thread.currentThread().getName() + "String_Node_Str");
  mainLoop:   for (; ; ) {
    taskLoop:     for (; ; ) {
      Task head=m_head.get();
      for (; ; ) {
        if (head == null) {
          if (m_stop)           break mainLoop;
 else           break taskLoop;
        }
        Task next=head.nextThreadPoolTask;
        if (m_head.compareAndSet(head,next)) {
          if (next == null) {
            if (!m_tail.compareAndSet(head,null)) {
              while (head.nextThreadPoolTask == null)               ;
              m_head.set(head.nextThreadPoolTask);
            }
          }
          break;
        }
        head=m_head.get();
      }
      head.nextThreadPoolTask=null;
      head.run();
    }
    m_idleThreads.incrementAndGet();
    try {
      m_sem.acquire();
    }
 catch (    InterruptedException ex) {
      if (s_logger.isLoggable(Level.WARNING))       s_logger.warning(Thread.currentThread().getName() + "String_Node_Str" + ex.toString());
      break;
    }
  }
  if (s_logger.isLoggable(Level.FINE))   s_logger.fine(Thread.currentThread().getName() + "String_Node_Str");
}
Program: 92459
Project: 92459
Buggy source:
public void run() throws IOException {
  if (s_logger.isLoggable(Level.FINE))   s_logger.fine("String_Node_Str");
  for (; ; ) {
    m_selector.select();
    Set<SelectionKey> selectedKeys=m_selector.selectedKeys();
    for (    SelectionKey key : selectedKeys) {
      ChannelHandler channelHandler=(ChannelHandler)key.attachment();
      channelHandler.handleReadyOps(m_executor);
    }
    selectedKeys.clear();
    while (m_strHead != null) {
      m_strHead.runInSelectorThread();
      SelectorThreadRunnable head=m_strHead;
      SelectorThreadRunnable next=m_strHead.nextSelectorThreadRunnable;
      if (next == null) {
        m_strHead=null;
        if (m_strTail.compareAndSet(head,null))         break;
        while (head.nextSelectorThreadRunnable == null)         ;
        next=head.nextSelectorThreadRunnable;
      }
      m_strHead=next;
      head.nextSelectorThreadRunnable=null;
    }
    if (m_state == ST_STOPPING) {
      if (m_selector.keys().size() == 0)       break;
      m_selector.wakeup();
    }
  }
  m_executor.shutdown();
  try {
    if (!m_executor.awaitTermination(m_config.shutdownTimeout,TimeUnit.SECONDS))     m_executor.shutdownNow();
    m_executor.awaitTermination(m_config.shutdownTimeout,TimeUnit.SECONDS);
  }
 catch (  InterruptedException ignored) {
  }
  if (s_logger.isLoggable(Level.FINE))   s_logger.fine("String_Node_Str");
}

Fixed version (ground truth):
public void run() throws IOException {
  if (s_logger.isLoggable(Level.FINE))   s_logger.fine("String_Node_Str");
  for (; ; ) {
    m_selector.select();
    Set<SelectionKey> selectedKeys=m_selector.selectedKeys();
    for (    SelectionKey key : selectedKeys) {
      ChannelHandler channelHandler=(ChannelHandler)key.attachment();
      channelHandler.handleReadyOps(m_executor);
    }
    selectedKeys.clear();
    while (m_strHead != null) {
      m_strHead.runInSelectorThread();
      SelectorThreadRunnable head=m_strHead;
      SelectorThreadRunnable next=m_strHead.nextSelectorThreadRunnable;
      if (next == null) {
        m_strHead=null;
        if (m_strTail.compareAndSet(head,null))         break;
        while (head.nextSelectorThreadRunnable == null)         ;
        next=head.nextSelectorThreadRunnable;
      }
      m_strHead=next;
      head.nextSelectorThreadRunnable=null;
    }
    if (m_state == ST_STOPPING) {
      if (m_selector.keys().size() == 0)       break;
      m_selector.wakeup();
    }
  }
  m_executor.shutdown();
  try {
    if (!m_executor.awaitTermination(m_config.shutdownTimeout,TimeUnit.SECONDS))     m_executor.shutdownNow();
    m_executor.awaitTermination(m_config.shutdownTimeout,TimeUnit.SECONDS);
  }
 catch (  InterruptedException ex) {
    if (s_logger.isLoggable(Level.WARNING))     s_logger.warning(ex.toString());
  }
  if (s_logger.isLoggable(Level.FINE))   s_logger.fine("String_Node_Str");
}
Program: 92462
Project: 92462
Buggy source:
/** 
 * Get the next element.
 * @return integer entry.
 */
public int getNext(){
  Integer value=null;
  if (count < max) {
    value=reader.readInt32();
    count++;
    return value;
  }
  return value;
}

Fixed version (ground truth):
/** 
 * Get the next element.
 * @return integer entry.
 */
public Integer getNext(){
  Integer value=null;
  if (count < max) {
    value=reader.readInt32();
    count++;
    return value;
  }
  return value;
}
Program: 92463
Project: 92463
Buggy source:
/** 
 * Compares with another Value instance by index.
 * @param obj type of Value to compare against
 * @return true if of type Value and equal, otherwise false.
 */
@Override public boolean equals(Object obj){
  if (this == obj)   return true;
  if (this == null)   return false;
  if (this.getClass() != obj.getClass())   return false;
  return index == ((Value)obj).index;
}

Fixed version (ground truth):
/** 
 * Compares with another Value instance by index.
 * @param obj type of Value to compare against
 * @return true if of type Value and equal, otherwise false.
 */
@Override public boolean equals(Object obj){
  if (this == obj)   return true;
  if (obj == null)   return false;
  if (this.getClass() != obj.getClass())   return false;
  return index == ((Value)obj).index;
}
Program: 92464
Project: 92464
Buggy source:
/** 
 * Gets the element at index.
 * @param index of the element in the array.
 * @return {@link Value} at provided index, or null if out of bounds.
 */
public Value get(int index){
  if (index > values.length) {
    return null;
  }
  return values[index];
}

Fixed version (ground truth):
/** 
 * Gets the element at index.
 * @param index of the element in the array.
 * @return {@link Value} at provided index, or null if out of bounds.
 */
public Value get(final int index){
  return index < values.length ? values[index] : null;
}
Program: 92465
Project: 92465
Buggy source:
/** 
 * Dispose of the dataset and the pool of readers.
 * @throws IOException if there was a problem accessing data file.
 */
@Override public void close() throws IOException {
  source.close();
  super.close();
}

Fixed version (ground truth):
/** 
 * Dispose of the dataset and the pool of readers.
 * @throws IOException if there was a problem accessing data file.
 */
@Override public void close() throws IOException {
  pool.close();
  source.close();
  super.close();
}
Program: 92466
Project: 92466
Buggy source:
/** 
 * Delete the file if it's a temporary file and it still exists. <p> If the file is not deleted the first time then retry forcing garbage  collection. If the file was used as a memory mapped buffer it may take time for the buffer to be released after the file handle.
 */
protected void deleteFile(){
  if (this.isTempFile) {
    int iterations=0;
    while (getFile().exists() && iterations < 10) {
      if (getFile().delete() == false) {
        System.gc();
        iterations++;
      }
    }
  }
}

Fixed version (ground truth):
/** 
 * Delete the file if it's a temporary file and it still exists. <p> If the file is not deleted the first time then retry forcing garbage  collection. If the file was used as a memory mapped buffer it may take time for the buffer to be released after the file handle.
 */
protected void deleteFile(){
  if (this.isTempFile) {
    int iterations=0;
    while (getFile().exists() && iterations < 10) {
      if (getFile().delete() == false) {
        try {
          Thread.sleep(100);
        }
 catch (        InterruptedException e) {
        }
        System.gc();
        iterations++;
      }
    }
  }
}
Program: 92470
Project: 92470
Buggy source:
int binarySearch(Integer profileId) throws IOException {
  return super.binarySearch(profileOffsets,profileId);
}

Fixed version (ground truth):
SearchResult binarySearch(Integer profileId) throws IOException {
  return super.binarySearch(profileOffsets,profileId);
}
Program: 92471
Project: 92471
Buggy source:
/** 
 * Searches the list of profile Ids and returns the profile if the profile id is valid.
 * @param profileId Id of the profile to be found
 * @return Profile related to the id, or null if none found
 * @throws IOException signals an I/O exception occurred
 */
public Profile findProfile(int profileId) throws IOException {
  int index=getProfileOffsetSearch().binarySearch(profileId);
  return index < 0 ? null : profiles.get(profileOffsets.get(index).getOffset());
}

Fixed version (ground truth):
/** 
 * Searches the list of profile Ids and returns the profile if the profile id is valid.
 * @param profileId Id of the profile to be found
 * @return Profile related to the id, or null if none found
 * @throws IOException signals an I/O exception occurred
 */
public Profile findProfile(int profileId) throws IOException {
  int index=getProfileOffsetSearch().binarySearch(profileId).getIndex();
  return index < 0 ? null : profiles.get(profileOffsets.get(index).getOffset());
}
Program: 92472
Project: 92472
Buggy source:
/** 
 * Increments the lowest score recorded for the signature that was found.
 */
void incrLowestScore(int value){
  super.lowestScore+=value;
}

Fixed version (ground truth):
/** 
 * Increments the lowest score recorded for the signature that was found.
 */
public void incrLowestScore(int value){
  super.lowestScore+=value;
}
Program: 92473
Project: 92473
Buggy source:
/** 
 * Reads a source GZip file and writes the uncompressed data to destination  file.
 * @param sourcePath path to GZip file to load from.
 * @param destinationPath path to file to write the uncompressed data to.
 * @returns current state of the update process
 * @throws IOException
 * @throws DataFormatException 
 */
private static AutoUpdateStatus decompress(File sourcePath,File destinationPath) throws IOException {
  AutoUpdateStatus status=AUTO_UPDATE_IN_PROGRESS;
  FileInputStream fis=new FileInputStream(sourcePath);
  try {
    FileOutputStream fos=new FileOutputStream(destinationPath);
    try {
      GZIPInputStream gzis=new GZIPInputStream(fis);
      try {
        byte[] buffer=new byte[INPUT_BUFFER];
        int len;
        while ((len=gzis.read(buffer)) > 0) {
          fos.write(buffer,0,len);
        }
      }
  finally {
        gzis.close();
      }
    }
  finally {
      fos.close();
    }
  }
  finally {
    fis.close();
  }
  return status;
}

Fixed version (ground truth):
/** 
 * Reads a source GZip file and writes the uncompressed data to destination  file.
 * @param sourcePath path to GZip file to load from.
 * @param destinationPath path to file to write the uncompressed data to.
 * @returns current state of the update process
 * @throws IOException
 * @throws DataFormatException 
 */
private static AutoUpdateStatus decompress(File sourcePath,File destinationPath) throws IOException {
  AutoUpdateStatus status=AUTO_UPDATE_IN_PROGRESS;
  FileInputStream fis=new FileInputStream(sourcePath);
  try {
    FileOutputStream fos=new FileOutputStream(destinationPath);
    try {
      GZIPInputStream gzis=new GZIPInputStream(fis);
      try {
        byte[] buffer=new byte[INPUT_BUFFER];
        int len=0;
        while ((len=gzis.read(buffer)) > 0) {
          fos.write(buffer,0,len);
        }
      }
  finally {
        gzis.close();
      }
    }
  finally {
      fos.close();
    }
  }
  finally {
    fis.close();
  }
  return status;
}
Program: 92474
Project: 92474
Buggy source:
/** 
 * Verifies that the data has been downloaded correctly by comparing an MD5 hash off the downloaded data with one taken before the data was sent, which is stored in a response header.
 * @param client The Premium data download connection.
 * @param pathToFile path to compressed data file that has been downloaded.
 * @return True if the hashes match, else false.
 */
private static AutoUpdateStatus checkedDownloadedFileMD5(final HttpURLConnection client,final File compressedTempFile) throws NoSuchAlgorithmException, IOException {
  AutoUpdateStatus status=AUTO_UPDATE_IN_PROGRESS;
  final String serverHash=client.getHeaderField("String_Node_Str");
  final String downloadHash=getMd5Hash(compressedTempFile);
  if (serverHash.equals(downloadHash) == false) {
    status=AUTO_UPDATE_ERR_MD5_VALIDATION_FAILED;
  }
  return status;
}

Fixed version (ground truth):
/** 
 * Verifies that the data has been downloaded correctly by comparing an MD5 hash off the downloaded data with one taken before the data was sent, which is stored in a response header.
 * @param client The Premium data download connection.
 * @param pathToFile path to compressed data file that has been downloaded.
 * @return True if the hashes match, else false.
 */
private static AutoUpdateStatus checkedDownloadedFileMD5(final HttpURLConnection client,final File compressedTempFile) throws NoSuchAlgorithmException, IOException {
  AutoUpdateStatus status=AUTO_UPDATE_IN_PROGRESS;
  final String serverHash=client.getHeaderField("String_Node_Str");
  final String downloadHash=getMd5Hash(compressedTempFile);
  if (serverHash != null || downloadHash.equals(serverHash) == false) {
    status=AUTO_UPDATE_ERR_MD5_VALIDATION_FAILED;
  }
  return status;
}
Program: 92475
Project: 92475
Buggy source:
/** 
 * @return number of misses (The number of times an item was not available).
 */
public long getCacheMisses(){
  return misses.get();
}

Fixed version (ground truth):
/** 
 * @return number of misses
 */
public long getCacheMisses(){
  return misses.get();
}
Program: 92476
Project: 92476
Buggy source:
/** 
 * @return number of requests (The number of requests made to the cache).
 */
public long getCacheRequests(){
  return requests.get();
}

Fixed version (ground truth):
/** 
 * @return number of requests
 */
public long getCacheRequests(){
  return requests.get();
}
Program: 92477
Project: 92477
Buggy source:
/** 
 * The value represented as a double.
 * @return A double representation of the only item in the list.
 * @throws IOException indicates an I/O exception occurred
 */
public double toDouble() throws IOException {
  if (property.isList) {
    throw new UnsupportedOperationException("String_Node_Str");
  }
  return get(0).toDouble();
}

Fixed version (ground truth):
/** 
 * The value represented as a double.
 * @return A double representation of the only item in the list.
 * @throws IOException indicates an I/O exception occurred
 */
public double toDouble() throws IOException {
  if (property.isList) {
    throw new UnsupportedOperationException("String_Node_Str");
  }
  if (super.isEmpty() != false) {
    return get(0).toDouble();
  }
  return 0;
}
Program: 92478
Project: 92478
Buggy source:
/** 
 * The value represented as a boolean. return A boolean representation of the only item in the list. MobileException Thrown if the method is called for a property with multiple values
 * @return return A boolean representation of the only item in the list
 * @throws IOException indicates an I/O exception occurred
 */
public boolean toBool() throws IOException {
  if (property.isList) {
    throw new UnsupportedOperationException("String_Node_Str");
  }
  return get(0).toBool();
}

Fixed version (ground truth):
/** 
 * The value represented as a boolean. return A boolean representation of the only item in the list. MobileException Thrown if the method is called for a property with multiple values
 * @return return A boolean representation of the only item in the list
 * @throws IOException indicates an I/O exception occurred
 */
public boolean toBool() throws IOException {
  if (property.isList) {
    throw new UnsupportedOperationException("String_Node_Str");
  }
  if (super.isEmpty() == false) {
    return get(0).toBool();
  }
  return false;
}
Program: 92479
Project: 92479
Buggy source:
/** 
 * Constructs a new provider with the dataset, controller and cache  specified.
 * @param dataSet
 * @param controller
 * @param cacheServiceInternal 
 */
Provider(Dataset dataSet,Controller controller,int cacheSize){
  this.detectionCount=new AtomicLong();
  this.dataSet=dataSet;
  this.controller=controller;
  this.methodCounts=new SortedList<MatchMethods,Long>(this.methodCounts.values().size(),1);
  this.methodCounts.add(MatchMethods.CLOSEST,0l);
  this.methodCounts.add(MatchMethods.NEAREST,0l);
  this.methodCounts.add(MatchMethods.NUMERIC,0l);
  this.methodCounts.add(MatchMethods.EXACT,0l);
  this.methodCounts.add(MatchMethods.NONE,0l);
  userAgentCache=cacheSize > 0 ? new Cache<String,MatchState>(cacheSize) : null;
}

Fixed version (ground truth):
/** 
 * Constructs a new provider with the dataset, controller and cache  specified.
 * @param dataSet
 * @param controller
 * @param cacheServiceInternal 
 */
Provider(Dataset dataSet,Controller controller,int cacheSize){
  this.detectionCount=new AtomicLong();
  this.dataSet=dataSet;
  this.controller=controller;
  int numberOfMethods=MatchMethods.values().length;
  this.methodCounts=new SortedList<MatchMethods,Long>(numberOfMethods,1);
  this.methodCounts.add(MatchMethods.CLOSEST,0l);
  this.methodCounts.add(MatchMethods.NEAREST,0l);
  this.methodCounts.add(MatchMethods.NUMERIC,0l);
  this.methodCounts.add(MatchMethods.EXACT,0l);
  this.methodCounts.add(MatchMethods.NONE,0l);
  userAgentCache=cacheSize > 0 ? new Cache<String,MatchState>(cacheSize) : null;
}
Program: 92480
Project: 92480
Buggy source:
public Integer getLowestScore(){
  if (lowestScore != null)   return lowestScore;
 else   return 0;
}

Fixed version (ground truth):
public Integer getLowestScore(){
  if (lowestScore == null) {
    lowestScore=0;
  }
  return lowestScore;
}
Program: 92481
Project: 92481
Buggy source:
public int getDifference(){
  return getLowestScore() == null ? 0 : getLowestScore();
}

Fixed version (ground truth):
public int getDifference(){
  int score=getLowestScore();
  System.out.println("String_Node_Str" + score);
  return score >= 0 ? score : 0;
}
Program: 92482
Project: 92482
Buggy source:
@Test public void API_AllHeadersNull(){
  Map<String,String> headers=new HashMap<String,String>();
  for (  String header : dataset.getHttpHeaders()) {
    headers.put(header,null);
  }
  System.out.println("String_Node_Str" + headers.size() + "String_Node_Str");
  try {
    fetchAllProperties(provider.match(headers));
  }
 catch (  IOException ex) {
    Logger.getLogger(Base.class.getName()).log(Level.SEVERE,null,ex);
  }
}

Fixed version (ground truth):
@Test public void API_AllHeadersNull(){
  Map<String,String> headers=new HashMap<String,String>();
  for (  String header : dataset.getHttpHeaders()) {
    headers.put(header,null);
  }
  try {
    fetchAllProperties(provider.match(headers));
  }
 catch (  IOException ex) {
    Logger.getLogger(Base.class.getName()).log(Level.SEVERE,null,ex);
  }
}
Program: 92483
Project: 92483
Buggy source:
private void fetchAllProperties(Match match) throws IOException {
  int checkSum=0;
  for (  Property property : match.dataSet.getProperties()) {
    String propName=property.getName();
    System.out.println("String_Node_Str" + propName + "String_Node_Str"+ match.getValues(propName));
    checkSum+=match.getValues(property.getName()).toString().hashCode();
  }
  System.out.println("String_Node_Str" + checkSum);
}

Fixed version (ground truth):
private void fetchAllProperties(Match match) throws IOException {
  long checkSum=0;
  for (  Property property : match.dataSet.getProperties()) {
    String propName=property.getName();
    System.out.println("String_Node_Str" + propName);
    if (match.getValues(property) != null) {
      System.out.print(match.getValues(property) + "String_Node_Str");
      checkSum+=match.getValues(propName).hashCode();
    }
    System.out.println("String_Node_Str");
  }
  System.out.println("String_Node_Str" + checkSum);
}
Program: 92484
Project: 92484
Buggy source:
@Test public void API_AllHeadersNull(){
  Map<String,String> headers=new HashMap<String,String>();
  for (  String header : dataset.getHttpHeaders()) {
    headers.put(header,null);
  }
  try {
    fetchAllProperties(provider.match(headers));
  }
 catch (  IOException ex) {
    Logger.getLogger(Base.class.getName()).log(Level.SEVERE,null,ex);
  }
}

Fixed version (ground truth):
@Test public void API_AllHeadersNull(){
  Map<String,String> headers=new HashMap<String,String>();
  for (  String header : dataset.getHttpHeaders()) {
    headers.put(header,null);
  }
  System.out.println("String_Node_Str" + headers.size() + "String_Node_Str");
  try {
    fetchAllProperties(provider.match(headers));
  }
 catch (  IOException ex) {
    Logger.getLogger(Base.class.getName()).log(Level.SEVERE,null,ex);
  }
}
Program: 92485
Project: 92485
Buggy source:
private void fetchAllProperties(Match match) throws IOException {
  int checkSum=0;
  for (  Property property : match.dataSet.getProperties()) {
    System.out.println("String_Node_Str" + property.getName() + "String_Node_Str"+ match.getValues(property.getName()));
    checkSum+=match.getValues(property.getName()).toString().hashCode();
  }
  System.out.println("String_Node_Str" + checkSum);
}

Fixed version (ground truth):
private void fetchAllProperties(Match match) throws IOException {
  int checkSum=0;
  for (  Property property : match.dataSet.getProperties()) {
    String propName=property.getName();
    System.out.println("String_Node_Str" + propName + "String_Node_Str"+ match.getValues(propName));
    checkSum+=match.getValues(property.getName()).toString().hashCode();
  }
  System.out.println("String_Node_Str" + checkSum);
}
Program: 92486
Project: 92486
Buggy source:
/** 
 * Matches each of the required headers.
 * @param match
 * @param headers
 * @param importantHeaders HTTP headers that exist in the dataset as well as in the list of headers that were passed to the function.
 * @return A map of Header => Match entries.
 * @throws IOException 
 */
private Map<String,Match> matchForHeaders(Match match,Map<String,String> headers,ArrayList<String> importantHeaders) throws IOException {
  Map<String,Match> matches=new HashMap<String,Match>();
  Match currentMatch=match;
  for (int i=0; i < importantHeaders.size(); i++) {
    matches.put(importantHeaders.get(i),currentMatch != null ? currentMatch : createMatch());
    currentMatch=null;
  }
  for (  Entry m : matches.entrySet()) {
    m.setValue(match((String)m.getKey(),(Match)m.getValue()));
  }
  return matches;
}

Fixed version (ground truth):
/** 
 * Matches each of the required headers.
 * @param match
 * @param headers
 * @param importantHeaders HTTP headers that exist in the dataset as well as in the list of headers that were passed to the function.
 * @return A map of Header => Match entries.
 * @throws IOException 
 */
private Map<String,Match> matchForHeaders(Match match,Map<String,String> headers,ArrayList<String> importantHeaders) throws IOException {
  Map<String,Match> matches=new HashMap<String,Match>();
  Match currentMatch=match;
  for (int i=0; i < importantHeaders.size(); i++) {
    matches.put(importantHeaders.get(i),currentMatch != null ? currentMatch : createMatch());
    currentMatch=null;
  }
  for (  Entry m : matches.entrySet()) {
    Match doMatch=match(headers.get((String)m.getKey()),(Match)m.getValue());
  }
  return matches;
}
Program: 92488
Project: 92488
Buggy source:
private static void getFeatureJavaScript(Map<String,String[]> results,List<String> features,Property property) throws IOException {
  String[] values=results.get(property.getName());
  if (values != null && values.length > 0) {
switch (property.valueType) {
case BOOL:
      try {
        features.add(String.format("String_Node_Str",property.getName().replace("String_Node_Str","String_Node_Str"),Boolean.parseBoolean(values[0]) ? "String_Node_Str" : "String_Node_Str"));
      }
 catch (      NumberFormatException ex) {
      }
    break;
case INT:
  try {
    features.add(String.format("String_Node_Str",property.getName(),Double.parseDouble(values[0])));
  }
 catch (  NumberFormatException ex) {
  }
case DOUBLE:
try {
  features.add(String.format("String_Node_Str",property.getName(),Double.parseDouble(values[0])));
}
 catch (NumberFormatException ex) {
}
break;
default :
features.add(String.format("String_Node_Str",property.getName(),stringJoin(fiftyone.properties.DetectionConstants.VALUE_SEPARATOR,values)));
break;
}
}
}

Fixed version (ground truth):
private static void getFeatureJavaScript(Map<String,String[]> results,List<String> features,Property property) throws IOException {
  String[] values=results.get(property.getName());
  if (values != null && values.length > 0) {
    String propName=property.getName().replace("String_Node_Str","String_Node_Str").replace("String_Node_Str","String_Node_Str");
switch (property.valueType) {
case BOOL:
      try {
        features.add(String.format("String_Node_Str",propName,Boolean.parseBoolean(values[0]) ? "String_Node_Str" : "String_Node_Str"));
      }
 catch (      NumberFormatException ex) {
      }
    break;
case INT:
  try {
    features.add(String.format("String_Node_Str",propName,Double.parseDouble(values[0])));
  }
 catch (  NumberFormatException ex) {
  }
case DOUBLE:
try {
  features.add(String.format("String_Node_Str",propName,Double.parseDouble(values[0])));
}
 catch (NumberFormatException ex) {
}
break;
default :
features.add(String.format("String_Node_Str",propName,stringJoin(fiftyone.properties.DetectionConstants.VALUE_SEPARATOR,values)));
break;
}
}
}
Program: 92489
Project: 92489
Buggy source:
/** 
 * Gets the next entity for retrieval and increments the iteration.
 * @return the next entity in the list.
 */
public T next(){
  try {
    T t=varList.get(offset);
    offset+=entityLength;
    index++;
    return t;
  }
 catch (  Exception ex) {
    return null;
  }
}

Fixed version (ground truth):
/** 
 * Gets the next entity for retrieval and increments the iteration.
 * @return the next entity in the list.
 */
public T next(){
  try {
    T t=varList.get(offset);
    offset+=varList.entityFactory.getLength(t);
    index++;
    return t;
  }
 catch (  Exception ex) {
    return null;
  }
}
Program: 92490
Project: 92490
Buggy source:
public StreamVariableListIterator(StreamVariableList<T> varList){
  this.varList=varList;
  size=varList.size();
  entityLength=varList.entityFactory.getLength();
  int offset=0;
  index=0;
}

Fixed version (ground truth):
public StreamVariableListIterator(StreamVariableList<T> varList){
  this.varList=varList;
  size=varList.size();
  int offset=0;
  index=0;
}
Program: 92491
Project: 92491
Buggy source:
@Override public void doFilter(ServletRequest request,ServletResponse response,FilterChain chain) throws IOException, ServletException {
  HttpServletRequest httpRequest=(HttpServletRequest)request;
  if (Bandwidth.getJavascript(httpRequest) != null) {
    HttpSession session=httpRequest.getSession();
    Cookie[] cookies=httpRequest.getCookies();
    String ServletPath=httpRequest.getServletPath();
    if (!ServletPath.equals("String_Node_Str")) {
      if (cookies != null && session != null) {
        Bandwidth.process((HttpServletRequest)request,(HttpServletResponse)response,session,cookies);
      }
    }
    chain.doFilter(request,response);
  }
}

Fixed version (ground truth):
@Override public void doFilter(ServletRequest request,ServletResponse response,FilterChain chain) throws IOException, ServletException {
  HttpServletRequest httpRequest=(HttpServletRequest)request;
  if (Bandwidth.getJavascript(httpRequest) != null) {
    HttpSession session=httpRequest.getSession();
    Cookie[] cookies=httpRequest.getCookies();
    String ServletPath=httpRequest.getServletPath();
    if (!ServletPath.equals("String_Node_Str")) {
      if (cookies != null && session != null) {
        Bandwidth.process((HttpServletRequest)request,(HttpServletResponse)response,session,cookies);
      }
    }
  }
  chain.doFilter(request,response);
}
Program: 92492
Project: 92492
Buggy source:
String[] getContentsArray(){
  if (parentContents == null) {
    if (canGoUp) {
      return new String[]{getBuilder().goUpLabel};
    }
    return new String[]{};
  }
  String[] results=new String[parentContents.length + (canGoUp ? 1 : 0)];
  if (canGoUp) {
    results[0]=getBuilder().goUpLabel;
  }
  for (int i=canGoUp ? 1 : 0; i < parentContents.length; i++) {
    results[i]=parentContents[i].getName();
  }
  return results;
}

Fixed version (ground truth):
String[] getContentsArray(){
  if (parentContents == null) {
    if (canGoUp) {
      return new String[]{getBuilder().goUpLabel};
    }
    return new String[]{};
  }
  String[] results=new String[parentContents.length + (canGoUp ? 1 : 0)];
  if (canGoUp) {
    results[0]=getBuilder().goUpLabel;
  }
  for (int i=0; i < parentContents.length; i++) {
    results[canGoUp ? i + 1 : i]=parentContents[i].getName();
  }
  return results;
}
Program: 92493
Project: 92493
Buggy source:
boolean fileIsMimeType(File file,String mimeType,MimeTypeMap mimeTypeMap){
  if (mimeType == null || mimeType.equals("String_Node_Str")) {
    return true;
  }
 else {
    String filename=file.toURI().toString();
    int dotPos=filename.lastIndexOf('.');
    if (dotPos == -1) {
      return false;
    }
    String fileExtension=filename.substring(dotPos + 1);
    String fileType=mimeTypeMap.getMimeTypeFromExtension(fileExtension);
    if (fileType == null) {
      return false;
    }
    if (fileType.equals(mimeType)) {
      return true;
    }
    int mimeTypeDelimiter=mimeType.lastIndexOf('/');
    if (mimeTypeDelimiter == -1) {
      return false;
    }
    String mimeTypeMainType=mimeType.substring(0,mimeTypeDelimiter);
    String mimeTypeSubtype=mimeType.substring(mimeTypeDelimiter + 1);
    if (!mimeTypeSubtype.equals("String_Node_Str")) {
      return false;
    }
    int fileTypeDelimiter=fileType.lastIndexOf('/');
    if (fileTypeDelimiter == -1) {
      return false;
    }
    String fileTypeMainType=fileType.substring(0,fileTypeDelimiter);
    if (fileTypeMainType.equals(mimeTypeMainType)) {
      return true;
    }
  }
  return false;
}

Fixed version (ground truth):
boolean fileIsMimeType(File file,String mimeType,MimeTypeMap mimeTypeMap){
  if (mimeType == null || mimeType.equals("String_Node_Str")) {
    return true;
  }
 else {
    String filename=file.toURI().toString();
    int dotPos=filename.lastIndexOf('.');
    if (dotPos == -1) {
      return false;
    }
    String fileExtension=filename.substring(dotPos + 1);
    if (fileExtension.endsWith("String_Node_Str"))     return mimeType.startsWith("String_Node_Str");
    String fileType=mimeTypeMap.getMimeTypeFromExtension(fileExtension);
    if (fileType == null) {
      return false;
    }
    if (fileType.equals(mimeType)) {
      return true;
    }
    int mimeTypeDelimiter=mimeType.lastIndexOf('/');
    if (mimeTypeDelimiter == -1) {
      return false;
    }
    String mimeTypeMainType=mimeType.substring(0,mimeTypeDelimiter);
    String mimeTypeSubtype=mimeType.substring(mimeTypeDelimiter + 1);
    if (!mimeTypeSubtype.equals("String_Node_Str")) {
      return false;
    }
    int fileTypeDelimiter=fileType.lastIndexOf('/');
    if (fileTypeDelimiter == -1) {
      return false;
    }
    String fileTypeMainType=fileType.substring(0,fileTypeDelimiter);
    if (fileTypeMainType.equals(mimeTypeMainType)) {
      return true;
    }
  }
  return false;
}