[Demonstration 1]

[Buggy Method]
public void updateMaze() {
    Point currentCoordinates;
    MazeCell currentCell;
    while (true) {
        if (this.mazeCellStack.isEmpty())
            return;
        currentCoordinates = this.mazeCellStack.peek();
        currentCell = this.getMazeCell(currentCoordinates);
        if (currentCell != null && this.hasUnvisitedNeighbours(currentCoordinates))
            break;
        this.mazeCellStack.pop();
    }
    boolean updating = true;
    int tries = 0;
    while (updating) {
        if (tries == 10)
            while (true) ;
        int direction = this.random.nextInt(4);
        Point newCoordinates = new Point(currentCoordinates);
        switch(direction) {
            case 0:
                if (currentCoordinates.y == 0)
                    continue;
                newCoordinates.setLocation(currentCoordinates.x, currentCoordinates.y - 1);
                break;
            case 1:
                if (currentCoordinates.x == (this.width - 1))
                    continue;
                newCoordinates.setLocation(currentCoordinates.x + 1, currentCoordinates.y);
                break;
            case 2:
                if (currentCoordinates.y == (this.height - 1))
                    continue;
                newCoordinates.setLocation(currentCoordinates.x, currentCoordinates.y + 1);
                break;
            case 3:
                if (currentCoordinates.x == 0)
                    continue;
                newCoordinates.setLocation(currentCoordinates.x - 1, currentCoordinates.y);
                break;
        }
        MazeCell newCell = this.getMazeCell(newCoordinates);
        if (newCell == null || newCell.isVisited())
            continue;
        switch(direction) {
            case 0:
                currentCell.removeWall(0);
                newCell.removeWall(2);
                break;
            case 1:
                currentCell.removeWall(1);
                newCell.removeWall(3);
                break;
            case 2:
                currentCell.removeWall(2);
                newCell.removeWall(0);
                break;
            case 3:
                currentCell.removeWall(3);
                newCell.removeWall(1);
                break;
        }
        this.maze[currentCoordinates.y][currentCoordinates.x] = currentCell;
        this.maze[newCoordinates.y][newCoordinates.x] = newCell;
        updating = false;
        this.visit(newCoordinates);
    }
}

[Buggy Hunk]
if(this.mazeCellStack.isEmpty())

[Patch]
if(this.mazeCellStack.isEmpty() && !this.checkIfMazeHasOtherUnvisitedCells())

[Demonstration 2]

[Buggy Method]
public Object writeReplace(final Object original) {
    if (original instanceof URIAffinity) {
        return Affinity.NONE;
    } else if (original == Affinity.LOCAL) {
        // Swap a local affinity with a node affinity with the name of this node
        return nodeAffinity;
    } else if (original instanceof AbstractEJBMetaData) {
        return new EJBMetaDataImpl((AbstractEJBMetaData<?, ?>) original);
    } else if (original instanceof RemoteExceptionCause) {
        // old clients will not have this class
        return ((RemoteExceptionCause) original).toPlainThrowable();
    }
    return original;
}

[Buggy Hunk]
return nodeAffinity;

[Patch]
return new NodeAffinity(connection.getRemoteEndpointName());

[Demonstration 3]

[Buggy Method]
@PrePersist
public void generate() {
    if (this.uuid == null) {
        UUID uuid = UUID.randomUUID();
        this.uuid = uuid.toString();
        this.timestamp = new Date(uuid.timestamp());
    }
}

[Buggy Hunk]
this.timestamp = new Date(uuid.timestamp());

[Patch]
this.timestamp = new Date(System.currentTimeMillis());