private void mergeWindows(SessionComplexEventChunk<StreamEvent> previousWindow,
                              SessionComplexEventChunk<StreamEvent> nextWindow) {
        //merge with the next window
        if (previousWindow.getFirst() != null &&
                previousWindow.getEndTimestamp() >= (nextWindow.getStartTimestamp() - sessionGap)) {

            if (nextWindow.hasNext()) {
                nextWindow.next();
            }

            nextWindow.insertBeforeCurrent(previousWindow.getFirst());
            nextWindow.setStartTimestamp(previousWindow.getStartTimestamp());
            previousWindow.clear();
        }
    }
Merge previous window with the next window.
modules/siddhi-core/src/main/java/io/siddhi/core/query/processor/stream/window/SessionWindowProcessor.java