[Demonstration 1]

[Buggy Method]
private float calculatePosition(int startX, int endX, long startTime, long endTime) {
    long t = System.currentTimeMillis();
    if (t > endTime) {
        return endX;
    } else
        return (float) (endX - startX) / (float) (endTime - startTime) * (float) (t - startTime) + (float) startX;
}

[Buggy Hunk]
long t = System.currentTimeMillis();

[Patch]
long t = ViewTime.getInstance().getCurrentTimeMilli();

[Demonstration 2]

[Buggy Method]
@Test
@DisplayName("Constructor throws if end date is before the beginning date")
public void testConstructorInvertedRange() {
    LocalDate now = LocalDate.now();
    assertThrows(IllegalArgumentException.class, () -> new LocalDateRange(now, now.minusDays(1)));
}

[Buggy Hunk]
public void testConstructorInvertedRange() {

[Patch]
public void testConstructorInvertedRange() throws Throwable {

[Demonstration 3]

[Buggy Method]
private static void loadGraph(TitanGraph g, Configuration conf) throws IOException {
    BatchGraph bg = new BatchGraph(g, VertexIDType.NUMBER, 500000);
    int propertySize = conf.getInt("property.size");
    int numProperty = conf.getInt("property.total");
    String nodeFile = conf.getString("data.node");
    String edgeFile = conf.getString("data.edge");
    int offset = conf.getBoolean("zero_indexed") ? 1 : 0;
    System.out.printf("nodeFile %s, edgeFile %s, propertySize %d\n", nodeFile, edgeFile, propertySize);
    String[] properties = new String[numProperty * 2];
    for (int i = 0; i < numProperty * 2; i += 2) {
        properties[i] = "attr" + i;
    }
    long c = 1L;
    try (BufferedReader br = new BufferedReader(new FileReader(nodeFile))) {
        for (String line; (line = br.readLine()) != null; ) {
            // Node file has funky carriage return ^M, so we read one more line to finish the node information
            // replace carriage return with dummy line
            line += '\02' + br.readLine();
            Iterator<String> tokens = Splitter.fixedLength(propertySize + 1).split(line).iterator();
            for (int i = 0; i < numProperty; i++) {
                // trim first delimiter character
                properties[i * 2 + 1] = tokens.next().substring(1);
            }
            // Hopefully reduces RPC trips.
            bg.addVertex(TitanId.toVertexId(c), properties);
            if (++c % 100000L == 0L) {
                System.out.println("Processed " + c + " nodes");
            }
        }
    }
    c = 1L;
    Object[] edgeProperties = new Object[4];
    edgeProperties[0] = "timestamp";
    edgeProperties[2] = "property";
    try (BufferedReader br = new BufferedReader(new FileReader(edgeFile))) {
        for (String line; (line = br.readLine()) != null; ) {
            List<String> tokens = Lists.newArrayList(Splitter.on(' ').limit(5).trimResults().split(line));
            Long id1 = Long.parseLong(tokens.get(0)) + offset;
            Long id2 = Long.parseLong(tokens.get(1)) + offset;
            String atype = tokens.get(2);
            edgeProperties[1] = Long.parseLong(tokens.get(3));
            edgeProperties[3] = tokens.get(4);
            Vertex v1 = bg.getVertex(TitanId.toVertexId(id1));
            Vertex v2 = bg.getVertex(TitanId.toVertexId(id2));
            bg.addEdge(null, v1, v2, atype, edgeProperties);
            if (++c % 100000L == 0L) {
                System.out.println("Processed " + c + " edges");
            }
        }
    }
    bg.commit();
}

[Buggy Hunk]
properties[i] = "attr" + i;

[Patch]
properties[i] = "attr" + (i / 2);