void validateFileLength(final Location location) throws IOException {
        final long recordEnd = location.getOffset() + location.getSize();

        //Check if the end of the record will go past the file length
        if (recordEnd > dataFile.length) {
            /*
             * AMQ-9254 if the read request is outside expected dataFile length,
             * perform expensive OS file length lookup operation to allow read
             * operation if it will succeed
             */
            final long osFileLength = dataFile.getFile().length();
            if(recordEnd > osFileLength) {
                throw new IOException("Invalid location size: " + location + ", size: " + location.getSize());
            } else {
                LOG.warn("DataFile:{} actual length:{} larger than expected:{} for readRecord location:{} size:{}",
                    dataFile.file.getName(), osFileLength, dataFile.length, location, location.getSize());
            }
        }
    }
@Test(expected = IOException.class)
    public void testInvalidLocationSize() throws IOException {
        //Create file of size 1024
        final DataFileAccessor accessor = new DataFileAccessor(mock(Journal.class),
            newTestDataFile(1024));

        //Set a size that is too large so this should fail
        final Location location = new Location(0, 100);
        location.setSize(2048);

        accessor.validateFileLength(location);
    }