Shouldn't this code have thrown a FileSystemLoopException instead?

Francis Galiegue fgaliegue at gmail.com
Thu Feb 5 15:50:19 UTC 2015


Test dir setup:

ln -s l2 l1
ln -s l1 l2

Java code:

final Random random = new Random();
final byte[] content = new byte[1024];
random.nextBytes(content);

final Path loop = baseDir.resolve("l1");

try (
    final OutputStream out = Files.newOutputStream(loop);
) {
    out.write(content);
} catch (FileSystemException e) {
    System.out.println(e.getClass().getSimpleName());
} catch (IOException wtf) {
    System.out.println("Meh, I didn't expect that...");
    wtf.printStackTrace(System.out);
}

Prints out:

FileSystemException

even though FileSystemLoopException is defined?

(note: Ubuntu Linux x86_64 14.10, "official" Oracle JDK 1.8u25)

-- 
Francis Galiegue, fgaliegue at gmail.com, https://github.com/fge
JSON Schema in Java: http://json-schema-validator.herokuapp.com
Parsers in pure Java: https://github.com/fge/grappa


More information about the nio-dev mailing list