nus-yam/ex-repair huggingface dataset:
Program: 58334
Project: 58334
Buggy source:
/** 
 * Handles mouse-pressed events on the connection skin to select / de-select the connection.
 * @param event the mouse-pressed event
 */
private void handleMousePressed(final MouseEvent event){
  if (event.isShortcutDown()) {
    setSelected(!isSelected());
  }
 else {
    getGraphEditor().getSelectionManager().clearSelection();
    setSelected(true);
  }
  event.consume();
}

Fixed version (ground truth):
/** 
 * Handles mouse-pressed events on the connection skin to select / de-select the connection.
 * @param event the mouse-pressed event
 */
private void handleMousePressed(final MouseEvent event){
  if (event.isShortcutDown()) {
    setSelected(!isSelected());
  }
 else   if (!isSelected()) {
    getGraphEditor().getSelectionManager().clearSelection();
    setSelected(true);
  }
  event.consume();
}
Program: 58335
Project: 58335
Buggy source:
/** 
 * Adds mouse handlers to the content to pan the   {@link PanningWindow} upon right mouse click-and-drag.
 */
private void addMouseHandlersToContent(){
  mousePressedHandler=event -> {
    if (!event.getButton().equals(MouseButton.SECONDARY)) {
      return;
    }
    setCursor(Cursor.MOVE);
    if (cacheWhilePanning) {
      content.setCache(true);
    }
    panningGestureActive=true;
    clickPosition=new Point2D(event.getSceneX(),event.getSceneY());
    windowXAtClick=windowXProperty().get();
    windowYAtClick=windowYProperty().get();
  }
;
  mouseDraggedHandler=event -> {
    if (!panningGestureActive) {
      return;
    }
    final Point2D currentPosition=new Point2D(event.getSceneX(),event.getSceneY());
    final double deltaX=currentPosition.getX() - clickPosition.getX();
    final double deltaY=currentPosition.getY() - clickPosition.getY();
    final double newWindowX=windowXAtClick - deltaX;
    final double newWindowY=windowYAtClick - deltaY;
    panTo(newWindowX,newWindowY);
  }
;
  mouseReleasedHandler=event -> {
    if (!event.getButton().equals(MouseButton.SECONDARY)) {
      return;
    }
    setCursor(null);
    if (cacheWhilePanning) {
      content.setCache(false);
    }
    panningGestureActive=false;
  }
;
  content.addEventHandler(MouseEvent.MOUSE_PRESSED,mousePressedHandler);
  content.addEventHandler(MouseEvent.MOUSE_DRAGGED,mouseDraggedHandler);
  content.addEventHandler(MouseEvent.MOUSE_RELEASED,mouseReleasedHandler);
}

Fixed version (ground truth):
/** 
 * Adds mouse handlers to the content to pan the   {@link PanningWindow} upon right mouse click-and-drag.
 */
private void addMouseHandlersToContent(){
  mousePressedHandler=event -> {
    if (!event.getButton().equals(MouseButton.SECONDARY)) {
      return;
    }
    startPanning(event.getSceneX(),event.getSceneY());
  }
;
  mouseDraggedHandler=event -> {
    if (!event.getButton().equals(MouseButton.SECONDARY)) {
      return;
    }
    if (!panningGestureActive) {
      startPanning(event.getSceneX(),event.getSceneY());
    }
    final Point2D currentPosition=new Point2D(event.getSceneX(),event.getSceneY());
    final double deltaX=currentPosition.getX() - clickPosition.getX();
    final double deltaY=currentPosition.getY() - clickPosition.getY();
    final double newWindowX=windowXAtClick - deltaX;
    final double newWindowY=windowYAtClick - deltaY;
    panTo(newWindowX,newWindowY);
  }
;
  mouseReleasedHandler=event -> {
    if (!event.getButton().equals(MouseButton.SECONDARY)) {
      return;
    }
    setCursor(null);
    if (cacheWhilePanning) {
      content.setCache(false);
    }
    panningGestureActive=false;
  }
;
  content.addEventHandler(MouseEvent.MOUSE_PRESSED,mousePressedHandler);
  content.addEventHandler(MouseEvent.MOUSE_DRAGGED,mouseDraggedHandler);
  content.addEventHandler(MouseEvent.MOUSE_RELEASED,mouseReleasedHandler);
}
Program: 58336
Project: 58336
Buggy source:
/** 
 * Handles mouse-pressed events.
 * @param event a {@link MouseEvent}
 */
protected void handleMousePressed(final MouseEvent event){
  if (!event.getButton().equals(MouseButton.PRIMARY)) {
    return;
  }
  if (cacheWhenStationary) {
    setCache(false);
  }
  storeClickValuesForDrag(event.getSceneX(),event.getSceneY());
  dragActive=true;
  event.consume();
}

Fixed version (ground truth):
/** 
 * Handles mouse-pressed events.
 * @param event a {@link MouseEvent}
 */
protected void handleMousePressed(final MouseEvent event){
  if (!event.getButton().equals(MouseButton.PRIMARY)) {
    return;
  }
  container=getContainer(this);
  if (cacheWhenStationary) {
    setCache(false);
  }
  final Point2D cursorPosition=getCursorPositionInContainer(event);
  storeClickValuesForDrag(cursorPosition.getX(),cursorPosition.getY());
  dragActive=true;
  event.consume();
}
Program: 58337
Project: 58337
Buggy source:
/** 
 * Handles mouse-dragged events.
 * @param event {@link MouseEvent}
 */
protected void handleMouseDragged(final MouseEvent event){
  if (!event.getButton().equals(MouseButton.PRIMARY)) {
    return;
  }
  if (!dragActive) {
    storeClickValuesForDrag(event.getSceneX(),event.getSceneY());
  }
  handleDrag(event.getSceneX(),event.getSceneY());
  dragActive=true;
  event.consume();
}

Fixed version (ground truth):
/** 
 * Handles mouse-dragged events.
 * @param event {@link MouseEvent}
 */
protected void handleMouseDragged(final MouseEvent event){
  if (!event.getButton().equals(MouseButton.PRIMARY)) {
    return;
  }
  if (!dragActive) {
    container=getContainer(this);
    final Point2D cursorPosition=getCursorPositionInContainer(event);
    storeClickValuesForDrag(cursorPosition.getX(),cursorPosition.getY());
  }
  final Point2D cursorPosition=getCursorPositionInContainer(event);
  handleDrag(cursorPosition.getX(),cursorPosition.getY());
  dragActive=true;
  event.consume();
}
Program: 58338
Project: 58338
Buggy source:
/** 
 * Handles a drag event to the given cursor position.
 * @param x the cursor x position
 * @param y the cursor y position
 */
private void handleDrag(final double x,final double y){
  if (dragEnabledXProperty.get()) {
    handleDragX(x);
  }
  if (dragEnabledYProperty.get()) {
    handleDragY(y);
  }
}

Fixed version (ground truth):
/** 
 * Handles a drag event to the given cursor position.
 * @param x the cursor x position relative to the container
 * @param y the cursor y position relative to the container
 */
private void handleDrag(final double x,final double y){
  if (dragEnabledXProperty.get()) {
    handleDragX(x);
  }
  if (dragEnabledYProperty.get()) {
    handleDragY(y);
  }
}
Program: 58339
Project: 58339
Buggy source:
/** 
 * Stores relevant layout values at the time of the last mouse click (mouse-pressed event).
 * @param x the scene-x position of the click event
 * @param y the scene-y position of the click event
 */
protected void storeClickValuesForDrag(final double x,final double y){
  lastLayoutX=getLayoutX();
  lastLayoutY=getLayoutY();
  lastMouseX=x;
  lastMouseY=y;
  final Region container=getContainer(this);
  if (container != null && container.getWidth() > 0) {
    lastParentWidth=container.getWidth();
  }
 else {
    lastParentWidth=Double.MAX_VALUE;
  }
  if (container != null && container.getHeight() > 0) {
    lastParentHeight=container.getHeight();
  }
 else {
    lastParentHeight=Double.MAX_VALUE;
  }
  if (container != null && container.getMaxWidth() > 0) {
    absoluteMaxWidth=container.getMaxWidth();
  }
 else {
    absoluteMaxWidth=Double.MAX_VALUE;
  }
  if (container != null && container.getMaxHeight() > 0) {
    absoluteMaxHeight=container.getMaxHeight();
  }
 else {
    absoluteMaxHeight=Double.MAX_VALUE;
  }
}

Fixed version (ground truth):
/** 
 * Stores relevant layout values at the time of the last mouse click (mouse-pressed event).
 * @param x the container-x position of the click event
 * @param y the container-y position of the click event
 */
protected void storeClickValuesForDrag(final double x,final double y){
  lastLayoutX=getLayoutX();
  lastLayoutY=getLayoutY();
  lastMouseX=x;
  lastMouseY=y;
  if (container != null && container.getWidth() > 0) {
    lastParentWidth=container.getWidth();
  }
 else {
    lastParentWidth=Double.MAX_VALUE;
  }
  if (container != null && container.getHeight() > 0) {
    lastParentHeight=container.getHeight();
  }
 else {
    lastParentHeight=Double.MAX_VALUE;
  }
  if (container != null && container.getMaxWidth() > 0) {
    absoluteMaxWidth=container.getMaxWidth();
  }
 else {
    absoluteMaxWidth=Double.MAX_VALUE;
  }
  if (container != null && container.getMaxHeight() > 0) {
    absoluteMaxHeight=container.getMaxHeight();
  }
 else {
    absoluteMaxHeight=Double.MAX_VALUE;
  }
}
Program: 58340
Project: 58340
Buggy source:
@Override protected void handleMouseDragged(final MouseEvent event){
  if (!(getParent() instanceof Region)) {
    return;
  }
 else   if (!event.getButton().equals(MouseButton.PRIMARY)) {
    setCursor(null);
    return;
  }
  if (!dragActive) {
    storeClickValuesForDrag(event.getSceneX(),event.getSceneY());
    storeClickValuesForResize(event.getX(),event.getY());
  }
  if (lastMouseRegion.equals(RectangleMouseRegion.INSIDE)) {
    super.handleMouseDragged(event);
  }
 else   if (!lastMouseRegion.equals(RectangleMouseRegion.OUTSIDE)) {
    handleResize(event.getSceneX(),event.getSceneY());
  }
  dragActive=true;
  event.consume();
}

Fixed version (ground truth):
@Override protected void handleMouseDragged(final MouseEvent event){
  if (!(getParent() instanceof Region)) {
    return;
  }
 else   if (!event.getButton().equals(MouseButton.PRIMARY)) {
    setCursor(null);
    return;
  }
  if (!dragActive) {
    final Point2D cursorPosition=getCursorPositionInContainer(event);
    storeClickValuesForDrag(cursorPosition.getX(),cursorPosition.getY());
    storeClickValuesForResize(event.getX(),event.getY());
  }
  if (lastMouseRegion.equals(RectangleMouseRegion.INSIDE)) {
    super.handleMouseDragged(event);
  }
 else   if (!lastMouseRegion.equals(RectangleMouseRegion.OUTSIDE)) {
    final Point2D cursorPosition=getCursorPositionInContainer(event);
    handleResize(cursorPosition.getX(),cursorPosition.getY());
  }
  dragActive=true;
  event.consume();
}
Program: 58341
Project: 58341
Buggy source:
/** 
 * Handles a resize event to the given cursor position.
 * @param x the cursor scene-x position
 * @param y the cursor scene-y position
 */
private void handleResize(final double x,final double y){
switch (lastMouseRegion) {
case NORTHEAST:
    handleResizeNorth(y);
  handleResizeEast(x);
break;
case NORTHWEST:
handleResizeNorth(y);
handleResizeWest(x);
break;
case SOUTHEAST:
handleResizeSouth(y);
handleResizeEast(x);
break;
case SOUTHWEST:
handleResizeSouth(y);
handleResizeWest(x);
break;
case NORTH:
handleResizeNorth(y);
break;
case SOUTH:
handleResizeSouth(y);
break;
case EAST:
handleResizeEast(x);
break;
case WEST:
handleResizeWest(x);
break;
case INSIDE:
break;
case OUTSIDE:
break;
}
}

Fixed version (ground truth):
/** 
 * Handles a resize event to the given cursor position.
 * @param x the cursor container-x position
 * @param y the cursor container-y position
 */
private void handleResize(final double x,final double y){
switch (lastMouseRegion) {
case NORTHEAST:
    handleResizeNorth(y);
  handleResizeEast(x);
break;
case NORTHWEST:
handleResizeNorth(y);
handleResizeWest(x);
break;
case SOUTHEAST:
handleResizeSouth(y);
handleResizeEast(x);
break;
case SOUTHWEST:
handleResizeSouth(y);
handleResizeWest(x);
break;
case NORTH:
handleResizeNorth(y);
break;
case SOUTH:
handleResizeSouth(y);
break;
case EAST:
handleResizeEast(x);
break;
case WEST:
handleResizeWest(x);
break;
case INSIDE:
break;
case OUTSIDE:
break;
}
}
Program: 58343
Project: 58343
Buggy source:
/** 
 * Handles mouse-pressed events on the given node.
 * @param event a mouse-pressed event
 * @param node the {@link GNode} on which this event occured
 */
private void handleNodePressed(final MouseEvent event,final GNode node){
  if (!event.getButton().equals(MouseButton.PRIMARY)) {
    return;
  }
  final GNodeSkin nodeSkin=skinLookup.lookupNode(node);
  if (!nodeSkin.isSelected()) {
    if (!event.isControlDown()) {
      deselectAll();
    }
 else {
      backupSelections();
    }
    nodeSkin.setSelected(true);
  }
 else {
    if (event.isControlDown()) {
      nodeSkin.setSelected(false);
    }
  }
  if (!nodeSkin.getRoot().isMouseInPositionForResize()) {
    selectionDragManager.bindPositions(node,model);
  }
  event.consume();
}

Fixed version (ground truth):
/** 
 * Handles mouse-pressed events on the given node.
 * @param event a mouse-pressed event
 * @param node the {@link GNode} on which this event occurred
 */
private void handleNodePressed(final MouseEvent event,final GNode node){
  if (!event.getButton().equals(MouseButton.PRIMARY)) {
    return;
  }
  final GNodeSkin nodeSkin=skinLookup.lookupNode(node);
  if (!nodeSkin.isSelected()) {
    if (!event.isControlDown()) {
      deselectAll();
    }
 else {
      backupSelections();
    }
    nodeSkin.setSelected(true);
  }
 else {
    if (event.isControlDown()) {
      nodeSkin.setSelected(false);
    }
  }
  if (!nodeSkin.getRoot().isMouseInPositionForResize()) {
    selectionDragManager.bindPositions(node,model);
  }
  event.consume();
}
Program: 58344
Project: 58344
Buggy source:
/** 
 * Initializes the selection tracker for the given model.
 * @param model the {@link GModel} instance being edited
 */
public void initialize(final GModel model){
  selectedNodes.clear();
  selectedJoints.clear();
  for (  final GNode node : model.getNodes()) {
    final GNodeSkin nodeSkin=skinLookup.lookupNode(node);
    nodeSkin.selectedProperty().addListener((observable,oldValue,newValue) -> {
      if (newValue && !selectedNodes.contains(node)) {
        selectedNodes.add(node);
      }
 else       if (!newValue && selectedNodes.contains(node)) {
        selectedNodes.remove(node);
      }
    }
);
  }
  for (  final GConnection connection : model.getConnections()) {
    for (    final GJoint joint : connection.getJoints()) {
      final GJointSkin jointSkin=skinLookup.lookupJoint(joint);
      jointSkin.selectedProperty().addListener((observable,oldValue,newValue) -> {
        if (newValue && !selectedJoints.contains(joint)) {
          selectedJoints.add(joint);
        }
 else         if (!newValue && selectedJoints.contains(joint)) {
          selectedJoints.remove(joint);
        }
      }
);
    }
  }
}

Fixed version (ground truth):
/** 
 * Initializes the selection tracker for the given model.
 * @param model the {@link GModel} instance being edited
 */
public void initialize(final GModel model){
  selectedNodes.clear();
  selectedJoints.clear();
  for (  final GNode node : model.getNodes()) {
    final GNodeSkin nodeSkin=skinLookup.lookupNode(node);
    if (nodeSkin.isSelected()) {
      selectedNodes.add(node);
    }
    nodeSkin.selectedProperty().addListener((observable,oldValue,newValue) -> {
      if (newValue && !selectedNodes.contains(node)) {
        selectedNodes.add(node);
      }
 else       if (!newValue && selectedNodes.contains(node)) {
        selectedNodes.remove(node);
      }
    }
);
  }
  for (  final GConnection connection : model.getConnections()) {
    for (    final GJoint joint : connection.getJoints()) {
      final GJointSkin jointSkin=skinLookup.lookupJoint(joint);
      if (jointSkin.isSelected()) {
        selectedJoints.add(joint);
      }
      jointSkin.selectedProperty().addListener((observable,oldValue,newValue) -> {
        if (newValue && !selectedJoints.contains(joint)) {
          selectedJoints.add(joint);
        }
 else         if (!newValue && selectedJoints.contains(joint)) {
          selectedJoints.remove(joint);
        }
      }
);
    }
  }
}
Program: 58345
Project: 58345
Buggy source:
@Override public int getItemViewType(int position){
  int numHeadersAndPlaceholders=getHeadersCount() * mNumColumns;
  if (position < numHeadersAndPlaceholders && (position % mNumColumns != 0)) {
    return mAdapter != null ? mAdapter.getViewTypeCount() : 1;
  }
  if (mAdapter != null && position >= numHeadersAndPlaceholders && position < numHeadersAndPlaceholders + mAdapter.getCount() + (mNumColumns - (mAdapter.getCount() % mNumColumns))) {
    int adjPosition=position - numHeadersAndPlaceholders;
    int adapterCount=mAdapter.getCount();
    if (adjPosition < adapterCount) {
      return mAdapter.getItemViewType(adjPosition);
    }
 else     if (adapterCount != 0) {
      return mAdapter.getItemViewType(adapterCount - 1);
    }
  }
  int numFootersAndPlaceholders=getFootersCount() * mNumColumns;
  if (mAdapter != null && position < numHeadersAndPlaceholders + mAdapter.getCount() + numFootersAndPlaceholders) {
    return mAdapter != null ? mAdapter.getViewTypeCount() : 1;
  }
  return AdapterView.ITEM_VIEW_TYPE_HEADER_OR_FOOTER;
}

Fixed version (ground truth):
@Override public int getItemViewType(int position){
  int numHeadersAndPlaceholders=getHeadersCount() * mNumColumns;
  if (position < numHeadersAndPlaceholders && (position % mNumColumns != 0)) {
    return mAdapter != null ? mAdapter.getViewTypeCount() : 1;
  }
  if (mAdapter != null && position >= numHeadersAndPlaceholders && position < numHeadersAndPlaceholders + mAdapter.getCount() + (mNumColumns - (mAdapter.getCount() % mNumColumns))) {
    int adjPosition=position - numHeadersAndPlaceholders;
    int adapterCount=mAdapter.getCount();
    if (adjPosition < adapterCount) {
      return mAdapter.getItemViewType(adjPosition);
    }
 else     if (adapterCount != 0 && mNumColumns != 1) {
      return mAdapter.getItemViewType(adapterCount - 1);
    }
  }
  int numFootersAndPlaceholders=getFootersCount() * mNumColumns;
  if (mAdapter != null && position < numHeadersAndPlaceholders + mAdapter.getCount() + numFootersAndPlaceholders) {
    return mAdapter != null ? mAdapter.getViewTypeCount() : 1;
  }
  return AdapterView.ITEM_VIEW_TYPE_HEADER_OR_FOOTER;
}
Program: 58347
Project: 58347
Buggy source:
@Override public Object getItem(int position){
  int numHeadersAndPlaceholders=getHeadersCount() * mNumColumns;
  if (position < numHeadersAndPlaceholders) {
    if (position % mNumColumns == 0) {
      return mHeaderViewInfos.get(position / mNumColumns).data;
    }
    return null;
  }
  if (position < numHeadersAndPlaceholders + mAdapter.getCount()) {
    final int adjPosition=position - numHeadersAndPlaceholders;
    int adapterCount=0;
    if (mAdapter != null) {
      adapterCount=mAdapter.getCount();
      if (adjPosition < adapterCount) {
        return mAdapter.getItem(adjPosition);
      }
    }
  }
  if (position < numHeadersAndPlaceholders + mAdapter.getCount() + (mAdapter.getCount() % mNumColumns)) {
    return null;
  }
  int numFootersAndPlaceholders=getFootersCount() * mNumColumns;
  if (position < numHeadersAndPlaceholders + mAdapter.getCount() + (mAdapter.getCount() % mNumColumns)+ numFootersAndPlaceholders) {
    if (position % mNumColumns == 0) {
      return mFooterViewInfos.get((position - numHeadersAndPlaceholders - mAdapter.getCount()- (mAdapter.getCount() % mNumColumns)) / mNumColumns).data;
    }
  }
  throw new ArrayIndexOutOfBoundsException(position);
}

Fixed version (ground truth):
@Override public Object getItem(int position){
  int numHeadersAndPlaceholders=getHeadersCount() * mNumColumns;
  if (position < numHeadersAndPlaceholders) {
    if (position % mNumColumns == 0) {
      return mHeaderViewInfos.get(position / mNumColumns).data;
    }
    return null;
  }
  if (position < numHeadersAndPlaceholders + mAdapter.getCount()) {
    final int adjPosition=position - numHeadersAndPlaceholders;
    int adapterCount=0;
    if (mAdapter != null) {
      adapterCount=mAdapter.getCount();
      if (adjPosition < adapterCount) {
        return mAdapter.getItem(adjPosition);
      }
    }
  }
  final int lastRowItemCount=(mAdapter.getCount() % mNumColumns);
  final int emptyItemCount=((lastRowItemCount == 0) ? 0 : mNumColumns - lastRowItemCount);
  if (position < numHeadersAndPlaceholders + mAdapter.getCount() + emptyItemCount) {
    return null;
  }
  int numFootersAndPlaceholders=getFootersCount() * mNumColumns;
  if (position < numHeadersAndPlaceholders + mAdapter.getCount() + emptyItemCount+ numFootersAndPlaceholders) {
    if (position % mNumColumns == 0) {
      return mFooterViewInfos.get((position - numHeadersAndPlaceholders - mAdapter.getCount()- emptyItemCount) / mNumColumns).data;
    }
  }
  throw new ArrayIndexOutOfBoundsException(position);
}
Program: 58348
Project: 58348
Buggy source:
@Override public int getCount(){
  if (mAdapter != null) {
    return (getHeadersCount() * mNumColumns) + mAdapter.getCount() + (mAdapter.getCount() % mNumColumns)+ (getFootersCount() * mNumColumns);
  }
 else {
    return (getHeadersCount() * mNumColumns) + (getFootersCount() * mNumColumns);
  }
}

Fixed version (ground truth):
@Override public int getCount(){
  if (mAdapter != null) {
    final int lastRowItemCount=(mAdapter.getCount() % mNumColumns);
    final int emptyItemCount=((lastRowItemCount == 0) ? 0 : mNumColumns - lastRowItemCount);
    return (getHeadersCount() * mNumColumns) + mAdapter.getCount() + emptyItemCount+ (getFootersCount() * mNumColumns);
  }
 else {
    return (getHeadersCount() * mNumColumns) + (getFootersCount() * mNumColumns);
  }
}
Program: 58350
Project: 58350
Buggy source:
@Override public boolean isEnabled(int position){
  int numHeadersAndPlaceholders=getHeadersCount() * mNumColumns;
  if (position < numHeadersAndPlaceholders) {
    return (position % mNumColumns == 0) && mHeaderViewInfos.get(position / mNumColumns).isSelectable;
  }
  if (position < numHeadersAndPlaceholders + mAdapter.getCount()) {
    final int adjPosition=position - numHeadersAndPlaceholders;
    int adapterCount=0;
    if (mAdapter != null) {
      adapterCount=mAdapter.getCount();
      if (adjPosition < adapterCount) {
        return mAdapter.isEnabled(adjPosition);
      }
    }
  }
  if (position < numHeadersAndPlaceholders + mAdapter.getCount() + (mAdapter.getCount() % mNumColumns)) {
    return false;
  }
  int numFootersAndPlaceholders=getFootersCount() * mNumColumns;
  if (position < numHeadersAndPlaceholders + mAdapter.getCount() + (mAdapter.getCount() % mNumColumns)+ numFootersAndPlaceholders) {
    return (position % mNumColumns == 0) && mFooterViewInfos.get((position - numHeadersAndPlaceholders - mAdapter.getCount()- (mAdapter.getCount() % mNumColumns)) / mNumColumns).isSelectable;
  }
  throw new ArrayIndexOutOfBoundsException(position);
}

Fixed version (ground truth):
@Override public boolean isEnabled(int position){
  int numHeadersAndPlaceholders=getHeadersCount() * mNumColumns;
  if (position < numHeadersAndPlaceholders) {
    return (position % mNumColumns == 0) && mHeaderViewInfos.get(position / mNumColumns).isSelectable;
  }
  if (position < numHeadersAndPlaceholders + mAdapter.getCount()) {
    final int adjPosition=position - numHeadersAndPlaceholders;
    int adapterCount=0;
    if (mAdapter != null) {
      adapterCount=mAdapter.getCount();
      if (adjPosition < adapterCount) {
        return mAdapter.isEnabled(adjPosition);
      }
    }
  }
  final int lastRowItemCount=(mAdapter.getCount() % mNumColumns);
  final int emptyItemCount=((lastRowItemCount == 0) ? 0 : mNumColumns - lastRowItemCount);
  if (position < numHeadersAndPlaceholders + mAdapter.getCount() + emptyItemCount) {
    return false;
  }
  int numFootersAndPlaceholders=getFootersCount() * mNumColumns;
  if (position < numHeadersAndPlaceholders + mAdapter.getCount() + emptyItemCount+ numFootersAndPlaceholders) {
    return (position % mNumColumns == 0) && mFooterViewInfos.get((position - numHeadersAndPlaceholders - mAdapter.getCount()- emptyItemCount) / mNumColumns).isSelectable;
  }
  throw new ArrayIndexOutOfBoundsException(position);
}
Program: 58351
Project: 58351
Buggy source:
@Override public int getItemViewType(int position){
  int numHeadersAndPlaceholders=getHeadersCount() * mNumColumns;
  if (position < numHeadersAndPlaceholders && (position % mNumColumns != 0)) {
    return mAdapter != null ? mAdapter.getViewTypeCount() : 1;
  }
  if (mAdapter != null && position >= numHeadersAndPlaceholders && position < numHeadersAndPlaceholders + mAdapter.getCount()) {
    int adjPosition=position - numHeadersAndPlaceholders;
    int adapterCount=mAdapter.getCount();
    if (adjPosition < adapterCount) {
      return mAdapter.getItemViewType(adjPosition);
    }
  }
  int numFootersAndPlaceholders=getFootersCount() * mNumColumns;
  if (mAdapter != null && position < numHeadersAndPlaceholders + mAdapter.getCount() + numFootersAndPlaceholders) {
    return mAdapter != null ? mAdapter.getViewTypeCount() : 1;
  }
  return AdapterView.ITEM_VIEW_TYPE_HEADER_OR_FOOTER;
}

Fixed version (ground truth):
@Override public int getItemViewType(int position){
  int numHeadersAndPlaceholders=getHeadersCount() * mNumColumns;
  if (position < numHeadersAndPlaceholders && (position % mNumColumns != 0)) {
    return mAdapter != null ? mAdapter.getViewTypeCount() : 1;
  }
  if (mAdapter != null && position >= numHeadersAndPlaceholders && position < numHeadersAndPlaceholders + mAdapter.getCount() + (mNumColumns - (mAdapter.getCount() % mNumColumns))) {
    int adjPosition=position - numHeadersAndPlaceholders;
    int adapterCount=mAdapter.getCount();
    if (adjPosition < adapterCount) {
      return mAdapter.getItemViewType(adjPosition);
    }
 else     if (adapterCount != 0) {
      return mAdapter.getItemViewType(adapterCount - 1);
    }
  }
  int numFootersAndPlaceholders=getFootersCount() * mNumColumns;
  if (mAdapter != null && position < numHeadersAndPlaceholders + mAdapter.getCount() + numFootersAndPlaceholders) {
    return mAdapter != null ? mAdapter.getViewTypeCount() : 1;
  }
  return AdapterView.ITEM_VIEW_TYPE_HEADER_OR_FOOTER;
}
Program: 58352
Project: 58352
Buggy source:
@Override protected void encode(){
  if (!content.matches("String_Node_Str")) {
    throw new OkapiException("String_Node_Str");
  }
  String start="String_Node_Str";
  String stop="String_Node_Str";
  int patternLength=start.length() + stop.length() + (10 * content.length())+ (checkOption == CheckDigit.MOD43 ? 10 : 0);
  StringBuilder dest=new StringBuilder(patternLength);
  dest.append(start);
  int counter=0;
  char checkDigit=' ';
  for (int i=0; i < content.length(); i++) {
    char c=content.charAt(i);
    int index=positionOf(c,LOOKUP);
    dest.append(CODE_39[index]);
    counter+=index;
  }
  if (checkOption == CheckDigit.MOD43) {
    counter=counter % 43;
    checkDigit=LOOKUP[counter];
    int index=positionOf(checkDigit,LOOKUP);
    if (checkDigit == ' ') {
      checkDigit='_';
    }
    encodeInfo+="String_Node_Str" + checkDigit + "String_Node_Str";
  }
  dest.append(stop);
  if (checkOption == CheckDigit.MOD43) {
    readable="String_Node_Str" + content + checkDigit+ "String_Node_Str";
  }
 else {
    readable="String_Node_Str" + content + "String_Node_Str";
  }
  pattern=new String[]{dest.toString()};
  row_count=1;
  row_height=new int[]{-1};
}

Fixed version (ground truth):
@Override protected void encode(){
  if (!content.matches("String_Node_Str")) {
    throw new OkapiException("String_Node_Str");
  }
  String start="String_Node_Str";
  String stop="String_Node_Str";
  int patternLength=start.length() + stop.length() + (10 * content.length())+ (checkOption == CheckDigit.MOD43 ? 10 : 0);
  StringBuilder dest=new StringBuilder(patternLength);
  dest.append(start);
  int counter=0;
  char checkDigit=' ';
  for (int i=0; i < content.length(); i++) {
    char c=content.charAt(i);
    int index=positionOf(c,LOOKUP);
    dest.append(CODE_39[index]);
    counter+=index;
  }
  if (checkOption == CheckDigit.MOD43) {
    counter=counter % 43;
    checkDigit=LOOKUP[counter];
    int index=positionOf(checkDigit,LOOKUP);
    dest.append(CODE_39[index]);
    if (checkDigit == ' ') {
      checkDigit='_';
    }
    encodeInfo+="String_Node_Str" + checkDigit + "String_Node_Str";
  }
  dest.append(stop);
  if (checkOption == CheckDigit.MOD43) {
    readable="String_Node_Str" + content + checkDigit+ "String_Node_Str";
  }
 else {
    readable="String_Node_Str" + content + "String_Node_Str";
  }
  pattern=new String[]{dest.toString()};
  row_count=1;
  row_height=new int[]{-1};
}
Program: 58353
Project: 58353
Buggy source:
/** 
 * Massages ZXing barcode reading results to make them easier to check against Okapi data.
 * @param s the barcode content
 * @param symbol the symbol which encoded the content
 * @return the massaged barcode content
 */
private static String massageZXingData(String s,Symbol symbol){
  if (symbol instanceof Ean || symbol instanceof Upc) {
    return s.substring(0,s.length() - 1);
  }
 else   if (symbol instanceof DataMatrix && symbol.getDataType() == DataType.GS1) {
    return s.substring(1).replace("String_Node_Str",Symbol.FNC1_STRING);
  }
 else   if (symbol instanceof QrCode && symbol.getDataType() == DataType.GS1) {
    return s.replace("String_Node_Str",Symbol.FNC1_STRING);
  }
 else {
    return s;
  }
}

Fixed version (ground truth):
/** 
 * Massages ZXing barcode reading results to make them easier to check against Okapi data.
 * @param s the barcode content
 * @param symbol the symbol which encoded the content
 * @return the massaged barcode content
 */
private static String massageZXingData(String s,Symbol symbol){
  if (symbol instanceof Ean || symbol instanceof Upc) {
    return s.substring(0,s.length() - 1);
  }
 else   if (symbol instanceof Code3Of9 && ((Code3Of9)symbol).getCheckDigit() == CheckDigit.MOD43) {
    return s.substring(0,s.length() - 1);
  }
 else   if (symbol instanceof DataMatrix && symbol.getDataType() == DataType.GS1) {
    return s.substring(1).replace("String_Node_Str",Symbol.FNC1_STRING);
  }
 else   if (symbol instanceof QrCode && symbol.getDataType() == DataType.GS1) {
    return s.replace("String_Node_Str",Symbol.FNC1_STRING);
  }
 else {
    return s;
  }
}
Program: 58356
Project: 58356
Buggy source:
public boolean hasSuccessExpectations(){
  return !expectedCodewords.isEmpty() && !expectedLog.isEmpty();
}

Fixed version (ground truth):
public boolean hasSuccessExpectations(){
  return !expectedCodewords.isEmpty();
}
Program: 58357
Project: 58357
Buggy source:
private CfMode character_subset_select(int input_position){
  if ((inputData[input_position] >= '0') && (inputData[input_position + 1] <= '9')) {
    return CfMode.MODEC;
  }
  if ((inputData[input_position] >= 128) && (inputData[input_position] <= 160)) {
    return CfMode.MODEA;
  }
  if ((inputData[input_position] >= 0) && (inputData[input_position] <= 31)) {
    return CfMode.MODEA;
  }
  return CfMode.MODEB;
}

Fixed version (ground truth):
private CfMode character_subset_select(int input_position){
  if ((inputData[input_position] >= '0') && (inputData[input_position] <= '9')) {
    return CfMode.MODEC;
  }
  if ((inputData[input_position] >= 128) && (inputData[input_position] <= 160)) {
    return CfMode.MODEA;
  }
  if ((inputData[input_position] >= 0) && (inputData[input_position] <= 31)) {
    return CfMode.MODEA;
  }
  return CfMode.MODEB;
}
Program: 58358
Project: 58358
Buggy source:
public Postnet(){
  this.mode=Mode.POSTNET;
  this.humanReadableLocation=HumanReadableLocation.NONE;
}

Fixed version (ground truth):
public Postnet(){
  this.mode=Mode.POSTNET;
  this.default_height=12;
  this.humanReadableLocation=HumanReadableLocation.NONE;
}
Program: 58359
Project: 58359
Buggy source:
@Override protected void plotSymbol(){
  int xBlock;
  int x, y, w, h;
  rectangles.clear();
  texts.clear();
  int baseY;
  if (humanReadableLocation == TOP) {
    baseY=getTheoreticalHumanReadableHeight();
  }
 else {
    baseY=0;
  }
  x=0;
  w=moduleWidth;
  for (xBlock=0; xBlock < pattern[0].length(); xBlock++) {
    if (pattern[0].charAt(xBlock) == 'L') {
      y=baseY;
      h=12;
    }
 else {
      y=baseY + 6;
      h=6;
    }
    rectangles.add(new Rectangle2D.Double(x,y,w,h));
    x+=(3 * moduleWidth);
  }
  symbol_width=((pattern[0].length() - 1) * 3 * moduleWidth) + moduleWidth;
  symbol_height=12;
  if (humanReadableLocation != NONE && !readable.isEmpty()) {
    double baseline;
    if (humanReadableLocation == TOP) {
      baseline=fontSize;
    }
 else {
      baseline=getHeight() + fontSize;
    }
    double centerX=getWidth() / 2.0;
    texts.add(new TextBox(centerX,baseline,readable));
  }
}

Fixed version (ground truth):
@Override protected void plotSymbol(){
  int xBlock, shortHeight;
  double x, y, w, h;
  rectangles.clear();
  texts.clear();
  int baseY;
  if (humanReadableLocation == TOP) {
    baseY=getTheoreticalHumanReadableHeight();
  }
 else {
    baseY=0;
  }
  x=0;
  w=moduleWidth;
  shortHeight=(int)(0.4 * default_height);
  for (xBlock=0; xBlock < pattern[0].length(); xBlock++) {
    if (pattern[0].charAt(xBlock) == 'L') {
      y=baseY;
      h=default_height;
    }
 else {
      y=baseY + default_height - shortHeight;
      h=shortHeight;
    }
    rectangles.add(new Rectangle2D.Double(x,y,w,h));
    x+=(2.5 * moduleWidth);
  }
  symbol_width=(int)Math.ceil(((pattern[0].length() - 1) * 2.5 * moduleWidth) + moduleWidth);
  symbol_height=default_height;
  if (humanReadableLocation != NONE && !readable.isEmpty()) {
    double baseline;
    if (humanReadableLocation == TOP) {
      baseline=fontSize;
    }
 else {
      baseline=getHeight() + fontSize;
    }
    double centerX=getWidth() / 2.0;
    texts.add(new TextBox(centerX,baseline,readable));
  }
}
Program: 58360
Project: 58360
Buggy source:
private void processBytes(int start,int length){
  int len=0;
  int chunkLen=0;
  BigInteger mantisa;
  BigInteger total;
  BigInteger word;
  mantisa=new BigInteger("String_Node_Str");
  total=new BigInteger("String_Node_Str");
  if (inputData.length == 1) {
    codeWords[codeWordCount++]=913;
    codeWords[codeWordCount++]=inputData[start];
  }
 else {
    if (inputData.length % 6 == 0) {
      codeWords[codeWordCount++]=924;
    }
 else {
      codeWords[codeWordCount++]=901;
    }
    while (len < length) {
      chunkLen=length - len;
      if (6 <= chunkLen) {
        chunkLen=6;
        len+=chunkLen;
        total=BigInteger.valueOf(0);
        while ((chunkLen--) != 0) {
          mantisa=BigInteger.valueOf(inputData[start++]);
          total=total.or(mantisa.shiftLeft(chunkLen * 8));
        }
        chunkLen=5;
        while ((chunkLen--) != 0) {
          word=total.mod(BigInteger.valueOf(900));
          codeWords[codeWordCount + chunkLen]=word.intValue();
          total=total.divide(BigInteger.valueOf(900));
        }
        codeWordCount+=5;
      }
 else {
        len+=chunkLen;
        while ((chunkLen--) != 0) {
          codeWords[codeWordCount++]=inputData[start++];
        }
      }
    }
  }
}

Fixed version (ground truth):
private void processBytes(int start,int length,EncodingMode lastMode){
  int len=0;
  int chunkLen=0;
  BigInteger mantisa;
  BigInteger total;
  BigInteger word;
  mantisa=new BigInteger("String_Node_Str");
  total=new BigInteger("String_Node_Str");
  if (length == 1 && lastMode == EncodingMode.TEX) {
    codeWords[codeWordCount++]=913;
    codeWords[codeWordCount++]=inputData[start];
  }
 else {
    if (length % 6 == 0) {
      codeWords[codeWordCount++]=924;
    }
 else {
      codeWords[codeWordCount++]=901;
    }
    while (len < length) {
      chunkLen=length - len;
      if (6 <= chunkLen) {
        chunkLen=6;
        len+=chunkLen;
        total=BigInteger.valueOf(0);
        while ((chunkLen--) != 0) {
          mantisa=BigInteger.valueOf(inputData[start++]);
          total=total.or(mantisa.shiftLeft(chunkLen * 8));
        }
        chunkLen=5;
        while ((chunkLen--) != 0) {
          word=total.mod(BigInteger.valueOf(900));
          codeWords[codeWordCount + chunkLen]=word.intValue();
          total=total.divide(BigInteger.valueOf(900));
        }
        codeWordCount+=5;
      }
 else {
        len+=chunkLen;
        while ((chunkLen--) != 0) {
          codeWords[codeWordCount++]=inputData[start++];
        }
      }
    }
  }
}
Program: 58363
Project: 58363
Buggy source:
@Override public boolean encode(){
  String dest;
  String inter;
  int i, sum, check;
  char c;
  content=content.toUpperCase(Locale.ENGLISH);
  if (!(content.matches("String_Node_Str"))) {
    error_msg="String_Node_Str";
    return false;
  }
  inter="String_Node_Str";
  for (i=0; (i < content.length()) && (inter.length() < 20); i++) {
    c=content.charAt(i);
    if ((c >= '0') && (c <= '9')) {
      inter+=c;
    }
    if (c == '-') {
      inter+=c;
    }
    if ((c >= 'A') && (c <= 'J')) {
      inter+='a';
      inter+=chKasutSet[(c - 'A')];
    }
    if ((c >= 'K') && (c <= 'O')) {
      inter+='b';
      inter+=chKasutSet[(c - 'K')];
    }
    if ((c >= 'U') && (c <= 'Z')) {
      inter+='c';
      inter+=chKasutSet[(c - 'U')];
    }
  }
  for (i=inter.length(); i < 20; i++) {
    inter+="String_Node_Str";
  }
  dest="String_Node_Str";
  sum=0;
  for (i=0; i < 20; i++) {
    dest+=JapanTable[positionOf(inter.charAt(i),kasutSet)];
    sum+=positionOf(inter.charAt(i),chKasutSet);
  }
  check=19 - (sum % 19);
  dest+=JapanTable[positionOf(chKasutSet[check],kasutSet)];
  dest+="String_Node_Str";
  encodeInfo+="String_Node_Str" + dest + "String_Node_Str";
  encodeInfo+="String_Node_Str" + check + "String_Node_Str";
  readable="String_Node_Str";
  pattern=new String[1];
  pattern[0]=dest;
  row_count=1;
  row_height=new int[1];
  row_height[0]=-1;
  plotSymbol();
  return true;
}

Fixed version (ground truth):
@Override public boolean encode(){
  String dest;
  String inter;
  int i, sum, check;
  char c;
  content=content.toUpperCase(Locale.ENGLISH);
  if (!(content.matches("String_Node_Str"))) {
    error_msg="String_Node_Str";
    return false;
  }
  inter="String_Node_Str";
  for (i=0; (i < content.length()) && (inter.length() < 20); i++) {
    c=content.charAt(i);
    if ((c >= '0') && (c <= '9')) {
      inter+=c;
    }
    if (c == '-') {
      inter+=c;
    }
    if ((c >= 'A') && (c <= 'J')) {
      inter+='a';
      inter+=CH_KASUT_SET[(c - 'A')];
    }
    if ((c >= 'K') && (c <= 'O')) {
      inter+='b';
      inter+=CH_KASUT_SET[(c - 'K')];
    }
    if ((c >= 'U') && (c <= 'Z')) {
      inter+='c';
      inter+=CH_KASUT_SET[(c - 'U')];
    }
  }
  for (i=inter.length(); i < 20; i++) {
    inter+="String_Node_Str";
  }
  dest="String_Node_Str";
  sum=0;
  for (i=0; i < 20; i++) {
    dest+=JAPAN_TABLE[positionOf(inter.charAt(i),KASUT_SET)];
    sum+=positionOf(inter.charAt(i),CH_KASUT_SET);
  }
  check=19 - (sum % 19);
  if (check == 19) {
    check=0;
  }
  dest+=JAPAN_TABLE[positionOf(CH_KASUT_SET[check],KASUT_SET)];
  dest+="String_Node_Str";
  encodeInfo+="String_Node_Str" + dest + "String_Node_Str";
  encodeInfo+="String_Node_Str" + check + "String_Node_Str";
  readable="String_Node_Str";
  pattern=new String[]{dest};
  row_count=1;
  row_height=new int[]{-1};
  plotSymbol();
  return true;
}
Program: 58365
Project: 58365
Buggy source:
@Override protected void plotSymbol(){
  int xBlock;
  int x, y, w, h;
  rectangles.clear();
  x=0;
  w=1;
  y=0;
  h=0;
  for (xBlock=0; xBlock < pattern[0].length(); xBlock++) {
switch (pattern[0].charAt(xBlock)) {
case 'A':
      y=0;
    h=5;
  break;
case 'D':
y=3;
h=5;
break;
case 'F':
y=0;
h=8;
break;
case 'T':
y=3;
h=2;
break;
}
Rectangle2D.Double rect=new Rectangle2D.Double(x,y,w,h);
rectangles.add(rect);
x+=2;
}
symbol_width=pattern[0].length() * 3;
symbol_height=8;
}

Fixed version (ground truth):
@Override protected void plotSymbol(){
  int xBlock, shortHeight, longHeight;
  double x, y, w, h;
  rectangles.clear();
  texts.clear();
  int baseY;
  if (humanReadableLocation == TOP) {
    baseY=getTheoreticalHumanReadableHeight();
  }
 else {
    baseY=0;
  }
  x=0;
  w=moduleWidth;
  y=0;
  h=0;
  shortHeight=(int)(0.25 * default_height);
  longHeight=(int)(0.625 * default_height);
  for (xBlock=0; xBlock < pattern[0].length(); xBlock++) {
switch (pattern[0].charAt(xBlock)) {
case 'A':
      y=baseY;
    h=longHeight;
  break;
case 'D':
y=baseY + default_height - longHeight;
h=longHeight;
break;
case 'F':
y=baseY;
h=default_height;
break;
case 'T':
y=baseY + default_height - longHeight;
h=shortHeight;
break;
}
Rectangle2D.Double rect=new Rectangle2D.Double(x,y,w,h);
rectangles.add(rect);
x+=(2.43 * w);
}
symbol_width=(int)Math.ceil(((pattern[0].length() - 1) * 2.43 * w) + w);
symbol_height=default_height;
if (humanReadableLocation != NONE && !readable.isEmpty()) {
double baseline;
if (humanReadableLocation == TOP) {
baseline=fontSize;
}
 else {
baseline=getHeight() + fontSize;
}
double centerX=getWidth() / 2.0;
texts.add(new TextBox(centerX,baseline,readable));
}
}
Program: 58380
Project: 58380
Buggy source:
@Override @Nonnull public ItemStack getCraftingResult(@Nonnull InventoryCrafting inv){
  System.out.println("String_Node_Str");
  ItemStack dyeStack=ItemStack.EMPTY;
  ItemStack dyeStack2=ItemStack.EMPTY;
  ItemStack inputStack=ItemStack.EMPTY;
  ItemStack outputStack=output.copy();
  int dyeIndex=0;
  int colorableIndex=0;
  for (int i=0; i < inv.getSizeInventory(); ++i) {
    ItemStack stack=inv.getStackInSlot(i);
    if (!stack.isEmpty()) {
      if (ColorHelper.isDye(stack) && dyeStack.isEmpty()) {
        dyeStack=stack.copy();
        dyeIndex=i;
      }
 else       if (ColorHelper.isDye(stack)) {
        dyeStack2=stack.copy();
      }
      if (stack.getItem() instanceof IColorableItem) {
        inputStack=stack;
        colorableIndex=i;
      }
    }
  }
  if (dyeStack.isEmpty() || inputStack.isEmpty()) {
    return ItemStack.EMPTY;
  }
  outputStack=ItemHelper.copyTag(outputStack,inputStack);
  IColorableItem colorableItem=((IColorableItem)outputStack.getItem());
  if (dyeStack2.isEmpty()) {
    colorableItem.applyColor(outputStack,ColorHelper.getDyeColor(dyeStack),dyeIndex < colorableIndex ? 0 : 1);
  }
 else {
    colorableItem.applyColor(outputStack,ColorHelper.getDyeColor(dyeStack),0);
    colorableItem.applyColor(outputStack,ColorHelper.getDyeColor(dyeStack2),1);
  }
  return outputStack;
}

Fixed version (ground truth):
@Override @Nonnull public ItemStack getCraftingResult(@Nonnull InventoryCrafting inv){
  ItemStack dyeStack=ItemStack.EMPTY;
  ItemStack dyeStack2=ItemStack.EMPTY;
  ItemStack inputStack=ItemStack.EMPTY;
  ItemStack outputStack=output.copy();
  int dyeIndex=0;
  int colorableIndex=0;
  for (int i=0; i < inv.getSizeInventory(); ++i) {
    ItemStack stack=inv.getStackInSlot(i);
    if (!stack.isEmpty()) {
      if (ColorHelper.isDye(stack) && dyeStack.isEmpty()) {
        dyeStack=stack.copy();
        dyeIndex=i;
      }
 else       if (ColorHelper.isDye(stack)) {
        dyeStack2=stack.copy();
      }
      if (stack.getItem() instanceof IColorableItem) {
        inputStack=stack;
        colorableIndex=i;
      }
    }
  }
  if (dyeStack.isEmpty() || inputStack.isEmpty()) {
    return ItemStack.EMPTY;
  }
  outputStack=ItemHelper.copyTag(outputStack,inputStack);
  IColorableItem colorableItem=((IColorableItem)outputStack.getItem());
  if (dyeStack2.isEmpty()) {
    colorableItem.applyColor(outputStack,ColorHelper.getDyeColor(dyeStack),dyeIndex < colorableIndex ? 0 : 1);
  }
 else {
    colorableItem.applyColor(outputStack,ColorHelper.getDyeColor(dyeStack),0);
    colorableItem.applyColor(outputStack,ColorHelper.getDyeColor(dyeStack2),1);
  }
  return outputStack;
}
Program: 58383
Project: 58383
Buggy source:
@EventHandler public void postInit(FMLPostInitializationEvent event){
  OreDictionaryArbiter.initialize();
  PacketHandler.postInit();
  proxy.postInit(event);
}

Fixed version (ground truth):
@EventHandler public void postInit(FMLPostInitializationEvent event){
  PacketHandler.postInit();
  proxy.postInit(event);
}
Program: 58384
Project: 58384
Buggy source:
@Override public boolean apply(@Nullable ItemStack input){
  if (input == null || input.isEmpty()) {
    return false;
  }
  IFluidHandlerItem handler=FluidUtil.getFluidHandler(input);
  if (handler == null) {
    return false;
  }
  if (fluid.isFluidStackIdentical(handler.drain(Fluid.BUCKET_VOLUME,false))) {
    return true;
  }
  return false;
}

Fixed version (ground truth):
@Override public boolean apply(@Nullable ItemStack input){
  if (input == null || input.isEmpty()) {
    return false;
  }
  IFluidHandlerItem handler=input.getCount() > 1 ? FluidUtil.getFluidHandler(ItemHelper.cloneStack(input,1)) : FluidUtil.getFluidHandler(input);
  if (handler == null) {
    return false;
  }
  if (fluid.isFluidStackIdentical(handler.drain(Fluid.BUCKET_VOLUME,false))) {
    return true;
  }
  return false;
}
Program: 58385
Project: 58385
Buggy source:
@Override public NonNullList<ItemStack> getRemainingItems(InventoryCrafting inv){
  NonNullList<ItemStack> ret=NonNullList.withSize(inv.getSizeInventory(),ItemStack.EMPTY);
  for (int i=0; i < ret.size(); i++) {
    ItemStack stack=inv.getStackInSlot(i);
    IFluidHandlerItem fluidHandler=FluidUtil.getFluidHandler(stack);
    if (fluidHandler == null) {
      ret.set(i,ForgeHooks.getContainerItem(stack));
    }
 else {
      fluidHandler.drain(Fluid.BUCKET_VOLUME,true);
      ret.set(i,fluidHandler.getContainer().copy());
    }
  }
  return ret;
}

Fixed version (ground truth):
@Override public NonNullList<ItemStack> getRemainingItems(InventoryCrafting inv){
  NonNullList<ItemStack> ret=NonNullList.withSize(inv.getSizeInventory(),ItemStack.EMPTY);
  for (int i=0; i < ret.size(); i++) {
    ItemStack stack=inv.getStackInSlot(i);
    IFluidHandlerItem handler=stack.getCount() > 1 ? FluidUtil.getFluidHandler(ItemHelper.cloneStack(stack,1)) : FluidUtil.getFluidHandler(stack);
    if (handler == null) {
      ret.set(i,ForgeHooks.getContainerItem(stack));
    }
 else {
      handler.drain(Fluid.BUCKET_VOLUME,true);
      ret.set(i,handler.getContainer().copy());
    }
  }
  return ret;
}
Program: 58387
Project: 58387
Buggy source:
@Override protected void decode(ChannelHandlerContext ctx,FMLProxyPacket msg,List<Object> out) throws Exception {
  ByteBuf payload=msg.payload();
  byte discriminator=payload.readByte();
  Class<? extends PacketBase> packetClass=this.packets.get(discriminator);
  if (packetClass == null) {
    throw new NullPointerException("String_Node_Str" + discriminator);
  }
  PacketBase pkt=packetClass.newInstance();
  pkt.decodeInto(ctx,payload.slice());
  EntityPlayer player;
switch (FMLCommonHandler.instance().getEffectiveSide()) {
case CLIENT:
    player=CoFHCore.proxy.getClientPlayer();
  handlePacketClient(pkt,player);
break;
case SERVER:
INetHandler netHandler=ctx.channel().attr(NetworkRegistry.NET_HANDLER).get();
player=((NetHandlerPlayServer)netHandler).playerEntity;
handlePacketServer(pkt,player);
break;
default :
}
}

Fixed version (ground truth):
@Override protected void decode(ChannelHandlerContext ctx,FMLProxyPacket msg,List<Object> out) throws Exception {
  ByteBuf payload=msg.payload();
  byte discriminator=payload.readByte();
  Class<? extends PacketBase> packetClass=this.packets.get(discriminator);
  if (packetClass == null) {
    throw new NullPointerException("String_Node_Str" + discriminator);
  }
  PacketBase pkt=packetClass.newInstance();
  pkt.decodeInto(ctx,payload.slice());
  EntityPlayer player;
  FMLLog.info(ctx.channel().attr(NetworkRegistry.CHANNEL_SOURCE).get().toString());
switch (ctx.channel().attr(NetworkRegistry.CHANNEL_SOURCE).get()) {
case CLIENT:
    player=CoFHCore.proxy.getClientPlayer();
  handlePacketClient(pkt,player);
break;
case SERVER:
INetHandler netHandler=ctx.channel().attr(NetworkRegistry.NET_HANDLER).get();
player=((NetHandlerPlayServer)netHandler).playerEntity;
handlePacketServer(pkt,player);
break;
default :
}
}
Program: 58388
Project: 58388
Buggy source:
@Override public void handleUpdateTag(NBTTagCompound tag){
  super.handleUpdateTag(tag);
  PacketHandler.handleNBTPacket(tag);
}

Fixed version (ground truth):
@Override public void handleUpdateTag(NBTTagCompound tag){
  PacketHandler.handleNBTPacket(tag);
}
Program: 58389
Project: 58389
Buggy source:
@Override public void onBlockHarvested(World world,BlockPos pos,IBlockState state,EntityPlayer player){
  if (!player.capabilities.isCreativeMode) {
    dropBlockAsItem(world,pos,state,0);
    world.setBlockState(pos,Blocks.AIR.getDefaultState(),7);
  }
}

Fixed version (ground truth):
@Override public void onBlockHarvested(World world,BlockPos pos,IBlockState state,EntityPlayer player){
  if (!player.capabilities.isCreativeMode) {
    dropBlockAsItem(world,pos,state,0);
  }
}
Program: 58390
Project: 58390
Buggy source:
@Override public String removeFrequency(String _,int freq){
  if (_ != dummy) {
    PacketHandler.sendToServer(new Packet(hostedChannel,freq));
  }
  return super.removeFrequency(hostedChannel,freq);
}

Fixed version (ground truth):
@Override public String removeFrequency(String string,int freq){
  if (string != dummy) {
    PacketHandler.sendToServer(new Packet(hostedChannel,freq));
  }
  return super.removeFrequency(hostedChannel,freq);
}