google / jimfs

An in-memory file system for Java 7+
Apache License 2.0
2.42k stars 278 forks source link

FileStore.getBlockSize() should return the configuration block size #183

Open ogregoire opened 2 years ago

ogregoire commented 2 years ago

The following test case fails for some reason.

  @Test
  void test() throws IOException {
    var blockSize = 1 << 12;
    var configuration = Configuration.unix().toBuilder().setBlockSize(blockSize).build();
    var fs = Jimfs.newFileSystem(configuration);
    var path = fs.getPath("/home/test/test.txt");
    var store = Files.getFileStore(path);
    assertThat(store.getBlockSize()).isEqualTo(blockSize);
  }

I'm explicitly setting the block size, but I get an IOException when the test case is run:

java.lang.UnsupportedOperationException
        at java.base/java.nio.file.FileStore.getBlockSize(FileStore.java:158)
        ...

I would expect the store to return the block size instead.

ogregoire commented 2 years ago

I noticed that the method is new since Java 10. So I guess that a multi-release JAR must be created.

I worked a bit on it and found that it's possible to create such multi-release jar with the following changes:

My only issue was with the tests, hence why I didn't provide a full-blown PR: I don't know how to make tests for a Multi-release project.