#vulnerable code 
                             RecordMetaDataForCache writeRecord(Record record) throws IOException {

		long start = System.nanoTime();
		writeToChannel(record.serialize(), writeChannel);

		int recordSize = record.getRecordSize();
		long recordOffset = writeOffset;
		writeOffset += recordSize;

		IndexFileEntry indexFileEntry = new IndexFileEntry(record.getKey(), recordSize, recordOffset, record.getSequenceNumber(), record.getFlags());
		indexFile.write(indexFileEntry);

		HaloDB.recordWriteLatency(System.nanoTime() - start);

		return new RecordMetaDataForCache(fileId, recordOffset, recordSize, record.getSequenceNumber());
	} 
                            #location 4 
                            #vulnerability type THREAD_SAFETY_VIOLATION
#fixed code
                             long getWriteOffset() {
		return writeOffset;
	}