#vulnerable code 
                                protected ComplexEvent createSendEvent(ComplexEvent originalEvent, Map<Integer, Object> aggregateAttributeValueMap) {
        ComplexEvent copiedEvent = null;
        if (originalEvent instanceof StreamEvent) {
            copiedEvent = streamEventCloner.copyStreamEvent((StreamEvent) originalEvent);
        } else if (originalEvent instanceof StateEvent) {
            copiedEvent = stateEventCloner.copyStateEvent((StateEvent) originalEvent);
        }

        for (Integer position : aggregateAttributePositionList) {
            copiedEvent.getOutputData()[position] = aggregateAttributeValueMap.get(position);
        }
        return copiedEvent;
    } 
                            #location 4 
                            #vulnerability type THREAD_SAFETY_VIOLATION
#fixed code
                                protected ComplexEvent createSendEvent(ComplexEvent originalEvent, Map<Integer, Object> aggregateAttributeValueMap) {
        ComplexEvent copiedEvent = cloneComplexEvent(originalEvent);

        for (Integer position : aggregateAttributePositionList) {
            copiedEvent.getOutputData()[position] = aggregateAttributeValueMap.get(position);
        }
        return copiedEvent;
    }