[Demonstration 1]

[Buggy Method]
public Map<String, Set<RecordValue>> getAt(long ts) {
    Map<String, Set<RecordValue>> at = new HashMap<>();
    for (Map.Entry<String, SortedMap<Interval, Set<RecordValue>>> stringSortedMapEntry : history.entrySet()) {
        String key = stringSortedMapEntry.getKey();
        SortedMap<Interval, Set<RecordValue>> intervalSetSortedMap = stringSortedMapEntry.getValue();
        int counter = 0;
        for (Map.Entry<Interval, Set<RecordValue>> intervalSetEntry : intervalSetSortedMap.entrySet()) {
            counter++;
            Interval interval = intervalSetEntry.getKey();
            Set<RecordValue> values = intervalSetEntry.getValue();
            if (interval.endTs > ts) {
                break;
            }
            at.put(key, values);
        }
        atCount++;
        atSum += counter;
    }
    at.entrySet().removeIf(next -> next.getValue().size() == 1 && next.getValue().iterator().next().isAbsent());
    return at;
}

[Buggy Hunk]
if (interval.endTs > ts) {

[Patch]
if (interval.endTs >= ts) {

[Demonstration 2]

[Buggy Method]
private TimeSeries createTimeSeries(long[] inputTs, double[] inputVal, Properties config) throws Exception {
    if (inputTs.length != inputVal.length) {
        logger.log(Level.SEVERE, "Number of timestamps does not match with number of values");
        return null;
    }
    TimeSeries ts = new TimeSeries();
    ts.meta.name = "meta_name";
    ts.meta.fileName = "array_input";
    // Creating time series from input arrays of ts and values
    for (int i = 0; i < inputTs.length; i++) {
        ts.append(inputTs[i], (float) inputVal[i]);
    }
    if (config.getProperty("NUM_FUTURE_WEEKS") != null) {
        num_future_weeks = new Integer(config.getProperty("NUM_FUTURE_WEEKS"));
    }
    if (config.getProperty("BASE_WINDOWS") != null) {
        base_window = new Integer(config.getProperty("BASE_WINDOWS"));
    }
    if (config.getProperty("PERIOD") != null) {
        period = new Integer(config.getProperty("PERIOD"));
    }
    // Creating time series for future
    long lastTime = ts.lastTime();
    for (int i = 1; i <= num_future_weeks * base_window; i++) {
        ts.append((lastTime + i * period), (float) 0.0);
    }
    if (config.getProperty("AGGREGATION") != null && config.getProperty("AGGREGATOR") != null) {
        window_size = new Integer(config.getProperty("AGGREGATION"));
        aggregator = config.getProperty("AGGREGATOR");
    }
    // Handle aggregation.
    if (window_size > 1) {
        ts.data = ts.aggregate(window_size, aggregator);
        ts.meta.name += "_" + aggregator + "_" + window_size;
    }
    return ts;
}

[Buggy Hunk]
period = new Integer(config.getProperty("PERIOD"));

[Patch]
period = new Long(config.getProperty("PERIOD"));

[Demonstration 3]

[Buggy Method]
@Override
protected void componentClosed() {
    tabbedContainer.removeActionListener(tabActionListener);
    for (JInternalFrame internalFrame : desktopPane.getAllFrames()) {
        NotifiableComponent.get(getTopComponent(internalFrame)).componentClosed();
    }
}

[Buggy Hunk]
NotifiableComponent.get(getTopComponent(internalFrame)).componentClosed();

[Patch]
internalFrame.dispose();