aboutsummaryrefslogtreecommitdiff
path: root/jimfs/src/main/java
AgeCommit message (Collapse)Author
2019-11-06fix Handler.getHostAddress() performance issueasie
Fixes #85 RELNOTES=n/a ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=278648767
2019-10-14Fix 6 ErrorProneStyle findings:clshepherd
* Constructors and methods with the same name should appear sequentially with no other code in between. Please re-order or re-name methods. * Use grouping parenthesis to make the operator precedence explicit ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=274188261
2019-10-04Change Jimfs PathMatchers to use the regex flags indicated by the ↵cgdecker
Configuration's canonical (rather than display) path normalization when the Configuration is set to use canonical normalization for path equality. This basically affects Windows-like configurations, as Windows/NTFS is the only file system (at least of those Jimfs has a built-in equivalent for) that uses these settings. Essentially, Windows does not normalize the case of file names when displaying paths but it does normalize them (case fold) for comparison and equality. On a real Windows file system, a PathMatcher for "glob:**.txt" or "glob:**.TXT" would match both files ending in ".txt" and files ending in ".TXT". Fixes https://github.com/google/jimfs/issues/91 RELNOTES=Fixed behavior of `PathMatcher`s for Windows-like configurations to do case-insensitive matching. ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=272959573
2019-10-04Mostly migrate off jsr305.cpovirk
- Mostly migrate to Checker Framework declaration annotations. - Migrate @GuardedBy to a custom annotation for now. (We would migrate to Error Prone's, but that's causing me problems as I experiment with JPMS.) Compare to b/69411537 for Guava. I've left @ParametersAreNonnullByDefault in place for now, but we'd need to remove it to fully eliminate the jsr305 dep. RELNOTES=Migrated from jsr305 `@Nullable` to Checker Framework `@NullableDecl`. In addition to the new dependency on the Checker Framework annotations, we keep the dependency on jsr305 for now so that we can keep using `@ParametersAreNonNullByDefault`. ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=272713254
2019-10-02Fix exception message - add missing closing parenthesisEvgeny Mandrikov
Fixes https://github.com/google/jimfs/pull/37 RELNOTES=n/a ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=272510710
2019-10-02Removed TODO comment for making heap disks configurable, assahmed10315
its already implemented Fixes #36 RELNOTES=n/a ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=272432078
2019-04-29Run google-java-format over all of JimFS.kak
RELNOTES=Run google-java-format over all of JimFS. ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=244231542
2019-04-18Enable GoodTime-API for JimFS. (#79)Ron Shapiro
RELNOTES=n/a ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=244183449
2019-03-21Fix an issue with Files.newOutputStream for Jimfs where it wouldn't truncate ↵cgdecker
the file if the TRUNCATE_EXISTING option was explicitly provided and the WRITE option wasn't. The code that handles TRUNCATE_EXISTING requires that WRITE also be present for it to do anything (because it's documented that it's ignored otherwise), but newOutputStream should always add the WRITE option if the user doesn't provide it because an OutputStream is obviously for writing. (This matches the default behavior of FileSystemProvider.newOutputStream as well.) Fixes #77 RELNOTES=Fixed an issue where `Files.newOutputStream` wouldn't truncate the file if the `TRUNCATE_EXISTING` option was explicitly provided and the `WRITE` option wasn't. ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=237818016
2017-06-14Introduce a meaningful .toString() for JimFS's Configuration class. Standard ↵diamondm
configurations have short, meaningful names (e.g. "Configuration{Unix}") while custom instances include the relevant details of the configuration. Resolves https://github.com/google/jimfs/issues/45 ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=158857133
2017-06-05Fix comparison in JimfsPath that will always return false (as ArrayDeque is notdiamondm
a List) to simply compare the collections' elements. Eclipse caught this issue, warning "Unlikely argument type for equals(): ImmutableList<Name> seems to be unrelated to Deque<Name>". Also applied two ErrorProne fixes to "Use grouping parenthesis to make the operator precedence explicit". ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=157605901
2016-04-01Ignore errors that prevent Jimfs.newFileSystem from working in an ↵cgdecker
environment where ServiceLoader doesn't work correctly to load the SystemJimfsFileSystemProvider. This is in relation to https://github.com/google/jimfs/issues/31... I don't entirely understand what's going on there, but it does seem like an exception being thrown from FileSystems.newFileSystem should not prevent the user from getting the FileSystem that's already been created just because it can't be cached. ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=118790127
2016-04-01Fix a potential issue where a JimfsFileSystem would not be removed from the ↵cgdecker
static cache if SystemJimfsFileSystemProvider isn't found in the installed providers list but can be loaded from its ClassLoader by ServiceLoader. ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=118472638
2016-03-23A couple attribute-related changes:cgdecker
- Throw UOE instead of IAE when attempting to set an attribute that can't be set at all during file creation. This matches the behavior of the real file system implementations. - Make the owner:owner attribute not settable during file creation, which also matches the actual behavior. ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=117965277
2016-03-22Small formatting fix.cgdecker
------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=117853112
2016-03-21Throw UOE when setting unsupported attributesJason Tedor
This commit modifies the behavior when setting unsupported attributes to throw an UnsupportedOperationException instead of an IllegalArgumentException. This is to make JimfsFileSystemProvider#createDirectory and JimfsFileSystemProvider#newByteChannel behave consistently with the Javadocs for FileSystemProvider#createDirectory and FileSystemProvider#newByteChannel which require an UnsupportedOperationException to be thrown when the array of attributes contains attributes which can not be set. In particular, these methods are invoked via Files#createTempDirectory and Files#createFile which have the same requirement regarding throwing an UnsupportedOperationException when the array of attributes contains attributes which can not be set. Most notably, this causes a discrepancy between the handling of Jimfs when configured to act like a Windows filesystem versus the behavior of sun.nio.fs.WindowsFileSystem where the former will throw an IllegalArgumentException if an attempt is made to set a POSIX attribute but the latter will throw an UnsupportedOperationException (consistent with the Javadocs).
2016-01-21Minor fixes in preparation for 1.1-rc1.cgdecker
- Add @since 1.1 to new public types (though neither of them should be used directly). - Also @deprecate the required public, no-arg constructors on those types. - Make SystemJimfsFileSystemProvider final. - Random whitespace fix. ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=112710083
2016-01-15Add a method for getting the Configuration that the Jimfs.newFileSystem() ↵cgdecker
overloads that don't take a Configuration use. This is primarily for allowing the user to create a modified version of that default configuration, which currently isn't possible without duplicating the logic to get the configuration. Also remove an unused constant. It's public, but it seems unlikely anyone's using it. ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=112255563
2016-01-12Partially rollback previous change adding Turkish path normalization.cgdecker
We've determined that NTFS does not do locale-dependent case mapping (and neither do any other file systems we know of), so providing this option is unnecessary and misleading. I'm leaving the removal of a TODO I had to consider allowing Turkish-correct case folding and also adding in some notes about the whole situation for posterity. ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=111990375
2016-01-12Add long-requested ability to configure the polling rate for the ↵cgdecker
WatchService that Jimfs creates for watching for directory changes. This is done in such a way that it doesn't make it awkward to create a new WatchService implementation in the future. Fixes https://github.com/google/jimfs/issues/14. ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=111885937
2016-01-07Add Turkish path normalizationBen Hamilton
2015-11-10Remove a check that is always false.cgdecker
------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=107379017
2015-06-03Format Jimfs with google-java-format.cgdecker
Made a bunch of manual fixes, but mostly pretty good. ------------- Created by MOE: http://code.google.com/p/moe-java MOE_MIGRATED_REVID=94692335
2015-04-22Couple interruption-related fixes for JimfsFileChannel.cgdecker
- tryLock() shouldn't handle interruption. - lock() should throw FileLockInterruptionException rather than ClosedByInterruptException. ------------- Created by MOE: http://code.google.com/p/moe-java MOE_MIGRATED_REVID=91829785
2015-04-17Several changes to JimfsFileChannel.cgdecker
- Update it to handle thread interruption for all methods that handle interruption in the default FileChannel implementation (with the exception of map(), for which we always throw UOE). For most methods that weren't already handling interruption, this mostly just means that if they're called on a thread that's already interrupted they'll throw ClosedByInterruptException and close the channel. Requested in GitHub issue #21. Also add tests for this. - Make it possible for FileChannel methods that don't use the channel's position (they have a parameter for a specific file position) to proceed concurrently with other FileChannel methods, which is specified as legal in the FileChannel docs: "Other operations, in particular those that take an explicit position, may proceed concurrently". ------------- Created by MOE: http://code.google.com/p/moe-java MOE_MIGRATED_REVID=91435386
2015-02-26Change URIs for Unix- and Windows-like paths to end with a / if the file is ↵cgdecker
a directory. See this issue: https://github.com/google/jimfs/issues/16 I was initially reluctant to do this because it seems strange to actually access the file system to convert a path to a URI, but this does in fact seem to be the behavior for actual Unix paths. Additionally, when looking into creating a ClassLoader that takes Path objects for the classpath, I noticed that URLClassLoader treats URLs that end with / differently (as directories) from those that don't, which indicates that there are real consequences for not doing this. Note: URLClassLoader is tied to the default file system via File/JarFile by default, so it's not like this change actually enables it to just work with Jimfs files (nor do I have any real reason to think you'd even want to do that, I was just curious). This involves changing the PathType API to take a boolean parameter indicating whether or not the file is a directory in its method for getting a URI path, which makes this an incompatible change that would probably require a 2.0 release (not that I expect anyone's actually implementing their own PathType). ------------- Created by MOE: http://code.google.com/p/moe-java MOE_MIGRATED_REVID=87278575
2015-02-25Change usages of deprecated Objects methods to MoreObjects.cgdecker
Also change usages of base.Objects methods to java.util.Objects where possible. ------------- Created by MOE: http://code.google.com/p/moe-java MOE_MIGRATED_REVID=87182713
2015-02-25Split JimfsFileSystemProvider up to work around classloader issues.cgdecker
See https://github.com/google/jimfs/issues/18 for more information. - SystemJimfsFileSystemProvider (which is loaded as a service by the system classloader) only serves as a cache of FileSystem instances as needed to make Paths.get(URI) work. - JimfsFileSystemProvider is the actual provider that is returned by JimfsFileSystem.provider(). It is a singleton and provides the real implementation of most of the FileSystemProvider methods, but does not cache FileSystem instances. We now create the FileSystem instances directly when the user calls Jimfs.newFileSystem rather than passing the Configuration off to FileSystems.newFileSystem. This should ensure no classloader issues when creating the FileSystem. Once created, the FileSystem itself is passed to FileSystems.newFileSystem. There should be no classloader issues here either, since the new SystemJimfsFileSystemProvider implementation does not deal with any other Jimfs-specific classes. Also add a test that fails without this change. ------------- Created by MOE: http://code.google.com/p/moe-java MOE_MIGRATED_REVID=87170296
2015-02-23Remove unused imports.cgdecker
------------- Created by MOE: http://code.google.com/p/moe-java MOE_MIGRATED_REVID=86811396
2015-02-19Widen the catch block around registering the URL Handler.cgdecker
------------- Created by MOE: http://code.google.com/p/moe-java MOE_MIGRATED_REVID=86639396
2015-02-18Add support for "jimfs:" protocol URLs.cgdecker
For URLs to work, Java has to be able to find a URLStreamHandler implementation for the URL protocol/scheme. There isn't any really ideal way to do this programatically, but what this CL does is add "com.google.common" to the "java.protocol.handler.pkgs" system property when JimfsFileSystemProvider is initialized. This means that when Java tries to create a URL with the "jimfs" protocol, it'll look for "jimfs.Handler" under "com.google.common", find it and use it. (Documentation of that behavior found here: http://docs.oracle.com/javase/8/docs/api/java/net/URL.html#URL-java.lang.String-java.lang.String-int-java.lang.String-) Fixes Github issue #13. ------------- Created by MOE: http://code.google.com/p/moe-java MOE_MIGRATED_REVID=86627713
2015-01-21Change JimfsOutputStream.flush() to do nothing rather than throw an ↵cgdecker
exception when the stream is already already closed. This matches the behavior of other core OutputStream implementations such as that returned by Files.newOutputStream(Path) for the default FileSystem and prevents an exception when nesting an OutputStream inside a BufferedOutputStream inside an OutputStreamWriter using try-with-resources under JDK8 (among any number of other situations that could cause the same problem). (Details: try-with-resources closes each declared resource in reverse order. Closing the OutputStreamWriter causes the BufferedOutputStream to be closed which causes the unbuffered OutputStream to be flushed and then closed. Closing the BufferedOutputStream then tries to flush the unbuffered OutputStream again. Prior to JDK8, any exception thrown by this flush() was swallowed and completely ignored; in JDK8, the behavior changed to (correctly) throw that exception.) ------------- Created by MOE: http://code.google.com/p/moe-java MOE_MIGRATED_REVID=84439059
2014-11-05Misc changes to FileTree.cgdecker
------------- Created by MOE: http://code.google.com/p/moe-java MOE_MIGRATED_REVID=73318805
2014-11-05Fix a minor style guide violation.cgdecker
------------- Created by MOE: http://code.google.com/p/moe-java MOE_MIGRATED_REVID=70269830
2014-11-05Fix java 8 compilation failure.cushon
Type inference changes prevent this code from compiling in java 8. In general, methods that declare type parameters without using them in any formal parameter declarations should be avoided. ------------- Created by MOE: http://code.google.com/p/moe-java MOE_MIGRATED_REVID=69903864
2014-06-10Move all classes to com.google.common.jimfs.Colin Decker
------------- Created by MOE: http://code.google.com/p/moe-java MOE_MIGRATED_REVID=68905401
2014-05-16Make closing a FileSystem also close all associated resources (streams, ↵Colin Decker
channels, watch services, etc.) and cause almost all other methods to throw ClosedFileSystemException, as per the spec of FileSystem.close(). Does not make Path methods that do not involve the file system itself throw, even if that would technically be the correct thing to do... just doesn't seem worth it to me. Fixes Github issues #3 and #4. ------------- Created by MOE: http://code.google.com/p/moe-java MOE_MIGRATED_REVID=67288036
2014-05-13Change JimfsFileSystemProvider to cache URI -> FileSystem mappings in a ↵Colin Decker
static map with weak values. To paraphrase the updated Javadoc: The cache is static to ensure that even when the provider isn't loaded by the system class loader, meaning that a new instance of it must be created each time one of the methods on FileSystems or Paths#get(URI) is called, cached file system instances are still available. The cache uses weak values so that it doesn't prevent file systems that are created but not closed from being garbage collected if no references to them are held elsewhere. This is a compromise between ensuring that any file URI continues to work as long as the file system hasn't been closed (which is technically the correct thing to do but unlikely to be something that most users care about) and ensuring that users don't get unexpected leaks of large amounts of memory because they're creating many file systems in tests but forgetting to close them (which seems likely to happen sometimes). Users that want to ensure that a file system won't be garbage collected just need to ensure they hold a reference to it somewhere for as long as they need it to stick around. ------------- Created by MOE: http://code.google.com/p/moe-java MOE_MIGRATED_REVID=66924231
2014-03-26Fix JimfsFileStore.getUsableSpace() to return unallocated space, not total. ↵Colin Decker
It's not clear from the Javadoc what exactly it should return, but checking the behavior of the real file system it does appear that usable space should be at most the unallocated space in the store. ------------- Created by MOE: http://code.google.com/p/moe-java MOE_MIGRATED_REVID=63807322
2014-03-14Add tests for moving and copying files from one JimfsFileSystem to another ↵Colin Decker
(moves/copies to FileSystems with different FileSystemProviders are handled by the Files class itself). Also fix an issue where attributes other than basic attributes were being copied from one file to a file on a different file system when COPY_ATTRIBUTES was specified--there's no guarantee that the other file system will support all the file attribute views the source file system does. ------------- Created by MOE: http://code.google.com/p/moe-java MOE_MIGRATED_REVID=63161492
2014-03-13When copying a file, move copying of regular file content outside the file ↵Colin Decker
system lock. Otherwise, concurrent copying of files is bottlenecked on the single lock and it's actually faster to copy using streams. ------------- Created by MOE: http://code.google.com/p/moe-java MOE_MIGRATED_REVID=63093748
2014-02-03Make support for links, symbolic links, SecureDirectoryStream and ↵Colin Decker
FileChannel/AsychronousFileChannel optional. Also change JimfsSecureDirectoryStream to check that it's open before each operation as the spec requires and add tests for that. ------------- Created by MOE: http://code.google.com/p/moe-java MOE_MIGRATED_REVID=60953646
2014-02-03Inline BlockList into RegularFile.Colin Decker
This means that HeapDisk now uses a RegularFile for its block cache (only using the methods that were on BlockList), but it also saves an additional object per regular file. ------------- Created by MOE: http://code.google.com/p/moe-java MOE_MIGRATED_REVID=60947141
2014-01-31Get rid of public UserPrincipals class, moving its contents to ↵Colin Decker
package-private UserLookupService. Users can now only specify default user/group for a file system (in Configuration.Builder) using strings, which seems fine. ------------- Created by MOE: http://code.google.com/p/moe-java MOE_MIGRATED_REVID=60805963
2014-01-30Change directories to *not* unset their link to the parent directory when ↵Colin Decker
they are unlinked. Instead, when the directory is then linked in a new directory (as in a move), the parent link is overwritten with a new entry. When the directory is deleted, the parent link remains as long as the file object hangs around (as long as a SecureDirectoryStream is open to it, or for the lifetime of the FileSystem if the working directory was deleted.). This matches the behavior observed running in Linux, the only environment I've tried that supports SecureDirectoryStream. ------------- Created by MOE: http://code.google.com/p/moe-java MOE_MIGRATED_REVID=60680760
2014-01-30Get rid of FileContent interface, changing all implementations to subclasses ↵Colin Decker
of File. While logically it seemed to make sense for the content of each file to be a separate object, it led to awkward code particularly when dealing with directories (since the content needed a reference to the File that contained it) and regular file streams/channels, which needed both a reference to the File and the content anyway. - ByteStore renamed to RegularFile. - DirectoryTable renamed to Directory. - DirectoryEntryMap inlined in to Directory. - SymbolicLink class added, which just contains a JimfsPath target. - Various code simplified to accept or return specific File subclasses. - Also re-add a package-info.java file, mostly just for @ParametersAreNonNullByDefault (for whatever good that does). This also has the effect of further reducing the number of objects per file in the file system. For example, where a directory was previously a File, DirectoryTable and DirectoryEntryMap, it's now just a Directory. ------------- Created by MOE: http://code.google.com/p/moe-java MOE_MIGRATED_REVID=60676208
2014-01-29Clarify comment in FileSystemView.toRealPath() about non-nullness of entry() ↵Colin Decker
return value.
2014-01-28Ensure that no SecureDirectoryStream operations will throw NPE when the ↵Colin Decker
directory the SDS references has been deleted.
2014-01-24Miscellaneous minor code simplifications.Colin Decker
------------- Created by MOE: http://code.google.com/p/moe-java MOE_MIGRATED_REVID=60174966
2014-01-24Clean up pom.xml files and change Jimfs to use auto-service to generate its ↵Colin Decker
META-INF/services file. ------------- Created by MOE: http://code.google.com/p/moe-java MOE_MIGRATED_REVID=60126893