The following code catch IOException: public static Flux read( Resource resource, long position, DataBufferFactory bufferFactory, int bufferSize) { try { if (resource.isFile()) { File file = resource.getFile(); return readAsynchronousFileChannel( () -> AsynchronousFileChannel.open(file.toPath(), StandardOpenOption.READ), position, bufferFactory, bufferSize); } } catch (IOException ignore) { // fallback to resource.readableChannel(), below } Flux result = readByteChannel(resource::readableChannel, bufferFactory, bufferSize); return position == 0 ? result : skipUntilByteCount(result, position); } The other method does not catch IOException: public static Flux read( Path path, DataBufferFactory bufferFactory, int bufferSize, OpenOption... options) {

    Assert.notNull(path, "Path must not be null");
    Assert.notNull(bufferFactory, "DataBufferFactory must not be null");
    Assert.isTrue(bufferSize > 0, "'bufferSize' must be > 0");
    if (options.length > 0) {
        for (OpenOption option : options) {
            Assert.isTrue(!(option == StandardOpenOption.APPEND || option == StandardOpenOption.WRITE),
                    () -> "'" + option + "' not allowed");
        }
    }

    return readAsynchronousFileChannel(() -> AsynchronousFileChannel.open(path, options),
            bufferFactory, bufferSize);
}

It is strange that the two methods handle exceptions differently.

Comment From: snicoll

One needs to skip to a given position, the other doesn't (hence the fallback). There's no fallback for the other one so I don't find this strange.

Going forward, we prefer a description of an actual problem you'd be facing (in the form of a small sample we can run ourselves) rather than copy/pasting our code.