}
Location readNextLocationDetails(Location start, final int type) throws ClosedJournalException, IOException {
// Try with the most immediate subsequent location among inflight writes:
Location asyncLocation = new Location(start.getDataFileId(), start.getPointer() + 1);
WriteCommand asyncWrite = journal.getInflightWrites().get(asyncLocation);
if (asyncWrite != null && asyncWrite.getLocation().isBatchControlRecord() && type != Location.BATCH_CONTROL_RECORD_TYPE) {
asyncLocation = new Location(start.getDataFileId(), start.getPointer() + 2);
asyncWrite = journal.getInflightWrites().get(asyncLocation);
}
if (asyncWrite != null) {
asyncLocation.setPointer(asyncWrite.getLocation().getPointer());
asyncLocation.setSize(asyncWrite.getLocation().getSize());
asyncLocation.setType(asyncWrite.getLocation().getType());
asyncLocation.setData(asyncWrite.getData());
return asyncLocation;
} else if (!journal.getInflightWrites().containsKey(start)) {
// Else read from file:
Lock threadLock = getOrCreateLock(Thread.currentThread(), start.getDataFileId());
shared.lock();