#vulnerable code 
                                private static long getCurrentQueueFileLength(final Path dataDir) throws IOException {
        return new RandomAccessFile(
                Files.list(dataDir).filter(p -> p.toString().endsWith("cq4")).findFirst().
                        orElseThrow(AssertionError::new).toFile(), "r").length();
    } 
                            #location 4 
                            #vulnerability type RESOURCE_LEAK
#fixed code
                                private static long getCurrentQueueFileLength(final Path dataDir) throws IOException {
        try (RandomAccessFile file = new RandomAccessFile(
                Files.list(dataDir).filter(p -> p.toString().endsWith("cq4")).findFirst().
                        orElseThrow(AssertionError::new).toFile(), "r")) {
            return file.length();
        }
    }