[SPARK-3546] InputStream of ManagedBuffer is not closed and causes running out of file descriptor

This would throw an NPE if an error occurred in `new RandomAccessFile` or `getChannel`. I suppose you move `new RandomAccessFile(file, "r").getChannel` before the `try` block. Before that method returns, there is no `FileChannel` that successfully opened and therefore needs closing.