#vulnerable code 
                                @Override
    public void addToWindow(Datum newDatum) {
        if (window.size() == 0) {
            // We don't know what weight to use for the first datum, so we wait
            // until we have the second one to actually process it.
            window.add(new DatumWithInfo(newDatum, 0));
        } else {
            int weight = newDatum.getTime() - getLatestDatum().getTime();
            if (window.size() == 1) {
                windowSum = new ArrayRealVector(newDatum.getMetrics()
                        .getDimension());
                // Remove and re-add first datum with the correct weight
                Datum first = window.remove().getDatum();
                // Assume same weight for first as for second
                addDatumWithWeight(first, weight);
            }

            addDatumWithWeight(newDatum, weight);
        }
    } 
                            #location 8 
                            #vulnerability type NULL_DEREFERENCE
#fixed code
                                @Override
    public void addToWindow(Datum newDatum) {
        if (window.size() == 0) {
            // We don't know what weight to use for the first datum, so we wait
            // until we have the second one to actually process it.
            window.add(new DatumWithInfo(newDatum, 0));
        } else {
            int weight = newDatum.getTime(timeColumn) - getLatestDatum().getTime(timeColumn);
            if (window.size() == 1) {
                windowSum = new ArrayRealVector(newDatum.getMetrics()
                        .getDimension());
                // Remove and re-add first datum with the correct weight
                Datum first = window.remove().getDatum();
                // Assume same weight for first as for second
                addDatumWithWeight(first, weight);
            }

            addDatumWithWeight(newDatum, weight);
        }
    }