Skip to content

Return configured block size from FileStore.getBlockSize() - #511

Open
tanvir-ux wants to merge 3 commits into
google:masterfrom
tanvir-ux:filestore-getblocksize
Open

Return configured block size from FileStore.getBlockSize()#511
tanvir-ux wants to merge 3 commits into
google:masterfrom
tanvir-ux:filestore-getblocksize

Conversation

@tanvir-ux

Copy link
Copy Markdown

FileStore.getBlockSize() was added in Java 10. Jimfs already keeps the configured size on HeapDisk (Configuration.setBlockSize), but JimfsFileStore never overrode the JDK method, so callers always got UnsupportedOperationException.

This implements getBlockSize() by returning disk.blockSize(). There is no @Override so the project still compiles on Java 8; on 10+ it overrides at runtime.

Fixes #183

The new test matches the repro from the issue (unix config, setBlockSize(1 << 12)). Direct calls go through JimfsFileStore.getBlockSize() so they compile on 8; a reflective call covers FileStore.getBlockSize() on 10+ and is skipped on 8.

Jimfs stored the block size on HeapDisk but never overrode
FileStore.getBlockSize(), so JDK 10+ callers got UnsupportedOperationException
even after Configuration.setBlockSize().

Fixes google#183
Comment thread jimfs/src/main/java/com/google/common/jimfs/JimfsFileStore.java Outdated
Comment thread jimfs/src/main/java/com/google/common/jimfs/JimfsFileStore.java Outdated
Comment thread jimfs/src/test/java/com/google/common/jimfs/ConfigurationTest.java Outdated
@chaoren chaoren added type=defect Bug, not working as expected P4 labels Aug 27, 2026
Comment thread jimfs/src/test/java/com/google/common/jimfs/ConfigurationTest.java Outdated
Covered by testFileSystemForCustomConfiguration.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

P4 type=defect Bug, not working as expected

Projects

None yet

Development

Successfully merging this pull request may close these issues.

FileStore.getBlockSize() should return the configuration block size

2 participants