diff --git a/google-cloud-nio-examples/README.md b/google-cloud-nio-examples/README.md
index b74d11a7..bddf1586 100644
--- a/google-cloud-nio-examples/README.md
+++ b/google-cloud-nio-examples/README.md
@@ -22,12 +22,12 @@ To run this example:
4. Run the sample with:
```
- java -cp google-cloud-contrib/google-cloud-nio/target/google-cloud-nio-0.7.1-SNAPSHOT-shaded.jar:google-cloud-contrib/google-cloud-nio-examples/target/google-cloud-nio-examples-0.7.1-SNAPSHOT.jar com.google.cloud.nio.examples.ListFilesystems
+ java -cp google-cloud-contrib/google-cloud-nio/target/google-cloud-nio-0.8.3-alpha-SNAPSHOT-shaded.jar:google-cloud-contrib/google-cloud-nio-examples/target/google-cloud-nio-examples-0.8.3-alpha-SNAPSHOT.jar com.google.cloud.nio.examples.ListFilesystems
```
Notice that it lists Google Cloud Storage, which it wouldn't if you ran it without the NIO jar:
```
- java -cp google-cloud-contrib/google-cloud-nio-examples/target/google-cloud-nio-examples-0.7.1-SNAPSHOT.jar com.google.cloud.nio.examples.ListFilesystems
+ java -cp google-cloud-contrib/google-cloud-nio-examples/target/google-cloud-nio-examples-0.8.3-alpha-SNAPSHOT.jar com.google.cloud.nio.examples.ListFilesystems
```
The sample doesn't have anything about Google Cloud Storage in it. It gets that ability from the NIO
diff --git a/google-cloud-nio-examples/pom.xml b/google-cloud-nio-examples/pom.xml
index 2b07df87..98221641 100644
--- a/google-cloud-nio-examples/pom.xml
+++ b/google-cloud-nio-examples/pom.xml
@@ -11,7 +11,7 @@
com.google.cloud
google-cloud-contrib
- 0.8.1-SNAPSHOT
+ 0.8.2-alpha
google-cloud-nio-examples
diff --git a/google-cloud-nio/README.md b/google-cloud-nio/README.md
index 7d7df3b7..74ec7674 100644
--- a/google-cloud-nio/README.md
+++ b/google-cloud-nio/README.md
@@ -26,16 +26,16 @@ If you are using Maven, add this to your pom.xml file
com.google.cloud
google-cloud-nio
- 0.8.0
+ 0.8.2-alpha
```
If you are using Gradle, add this to your dependencies
```Groovy
-compile 'com.google.cloud:google-cloud-nio:0.8.0'
+compile 'com.google.cloud:google-cloud-nio:0.8.2-alpha'
```
If you are using SBT, add this to your dependencies
```Scala
-libraryDependencies += "com.google.cloud" % "google-cloud-nio" % "0.8.0"
+libraryDependencies += "com.google.cloud" % "google-cloud-nio" % "0.8.2-alpha"
```
Example Applications
diff --git a/google-cloud-nio/pom.xml b/google-cloud-nio/pom.xml
index 0646be3f..297938dd 100644
--- a/google-cloud-nio/pom.xml
+++ b/google-cloud-nio/pom.xml
@@ -11,7 +11,7 @@
com.google.cloud
google-cloud-contrib
- 0.8.1-SNAPSHOT
+ 0.8.2-alpha
google-cloud-nio
diff --git a/google-cloud-nio/src/main/java/com/google/cloud/storage/contrib/nio/CloudStorageFileSystem.java b/google-cloud-nio/src/main/java/com/google/cloud/storage/contrib/nio/CloudStorageFileSystem.java
index 60a39fb5..4f031c92 100644
--- a/google-cloud-nio/src/main/java/com/google/cloud/storage/contrib/nio/CloudStorageFileSystem.java
+++ b/google-cloud-nio/src/main/java/com/google/cloud/storage/contrib/nio/CloudStorageFileSystem.java
@@ -27,6 +27,7 @@
import java.net.URISyntaxException;
import java.nio.file.FileStore;
import java.nio.file.FileSystem;
+import java.nio.file.FileSystems;
import java.nio.file.Path;
import java.nio.file.PathMatcher;
import java.nio.file.WatchService;
@@ -210,13 +211,9 @@ public Set supportedFileAttributeViews() {
return SUPPORTED_VIEWS;
}
- /**
- * Throws {@link UnsupportedOperationException} because this feature hasn't been implemented yet.
- */
@Override
public PathMatcher getPathMatcher(String syntaxAndPattern) {
- // TODO(#813): Implement me.
- throw new UnsupportedOperationException();
+ return FileSystems.getDefault().getPathMatcher(syntaxAndPattern);
}
/**
diff --git a/google-cloud-nio/src/main/java/com/google/cloud/storage/contrib/nio/CloudStorageFileSystemProvider.java b/google-cloud-nio/src/main/java/com/google/cloud/storage/contrib/nio/CloudStorageFileSystemProvider.java
index 727327d2..f65549b6 100644
--- a/google-cloud-nio/src/main/java/com/google/cloud/storage/contrib/nio/CloudStorageFileSystemProvider.java
+++ b/google-cloud-nio/src/main/java/com/google/cloud/storage/contrib/nio/CloudStorageFileSystemProvider.java
@@ -170,14 +170,15 @@ public CloudStorageFileSystem getFileSystem(URI uri) {
}
/**
- * Returns Cloud Storage file system, provided a URI with no path, e.g. {@code gs://bucket}.
+ * Returns Cloud Storage file system, provided a URI, e.g. {@code gs://bucket}.
+ * The URI can include a path component (that will be ignored).
*
* @param uri bucket and current working directory, e.g. {@code gs://bucket}
* @param env map of configuration options, whose keys correspond to the method names of
* {@link CloudStorageConfiguration.Builder}. However you are not allowed to set the working
* directory, as that should be provided in the {@code uri}
- * @throws IllegalArgumentException if {@code uri} specifies a user, query, fragment, or scheme is
- * not {@value CloudStorageFileSystem#URI_SCHEME}
+ * @throws IllegalArgumentException if {@code uri} specifies a port, user, query, or fragment, or
+ * if scheme is not {@value CloudStorageFileSystem#URI_SCHEME}
*/
@Override
public CloudStorageFileSystem newFileSystem(URI uri, Map env) {
@@ -191,11 +192,10 @@ public CloudStorageFileSystem newFileSystem(URI uri, Map env) {
CloudStorageFileSystem.URI_SCHEME, uri);
checkArgument(
uri.getPort() == -1
- && isNullOrEmpty(uri.getPath())
&& isNullOrEmpty(uri.getQuery())
&& isNullOrEmpty(uri.getFragment())
&& isNullOrEmpty(uri.getUserInfo()),
- "GCS FileSystem URIs mustn't have: port, userinfo, path, query, or fragment: %s",
+ "GCS FileSystem URIs mustn't have: port, userinfo, query, or fragment: %s",
uri);
CloudStorageUtil.checkBucket(uri.getHost());
initStorage();
diff --git a/google-cloud-nio/src/test/java/com/google/cloud/storage/contrib/nio/CloudStorageFileSystemProviderTest.java b/google-cloud-nio/src/test/java/com/google/cloud/storage/contrib/nio/CloudStorageFileSystemProviderTest.java
index 86e87d0e..970d6021 100644
--- a/google-cloud-nio/src/test/java/com/google/cloud/storage/contrib/nio/CloudStorageFileSystemProviderTest.java
+++ b/google-cloud-nio/src/test/java/com/google/cloud/storage/contrib/nio/CloudStorageFileSystemProviderTest.java
@@ -54,7 +54,9 @@
import java.nio.file.OpenOption;
import java.nio.file.Path;
import java.nio.file.Paths;
+import java.util.HashMap;
import java.util.List;
+import java.util.Map;
/**
* Unit tests for {@link CloudStorageFileSystemProvider}.
@@ -644,6 +646,12 @@ public void testProviderEquals() {
assertThat(path1.getFileSystem().provider()).isNotEqualTo(path3.getFileSystem().provider());
}
+ @Test
+ public void testNewFileSystem() throws IOException {
+ Map env = new HashMap<>();
+ FileSystems.newFileSystem(URI.create("gs://bucket/path/to/file"), env);
+ }
+
private static CloudStorageConfiguration permitEmptyPathComponents(boolean value) {
return CloudStorageConfiguration.builder().permitEmptyPathComponents(value).build();
}
diff --git a/google-cloud-nio/src/test/java/com/google/cloud/storage/contrib/nio/CloudStorageFileSystemTest.java b/google-cloud-nio/src/test/java/com/google/cloud/storage/contrib/nio/CloudStorageFileSystemTest.java
index ec856447..d7d5b346 100644
--- a/google-cloud-nio/src/test/java/com/google/cloud/storage/contrib/nio/CloudStorageFileSystemTest.java
+++ b/google-cloud-nio/src/test/java/com/google/cloud/storage/contrib/nio/CloudStorageFileSystemTest.java
@@ -34,6 +34,7 @@
import java.nio.file.FileSystems;
import java.nio.file.Files;
import java.nio.file.Path;
+import java.nio.file.PathMatcher;
import java.nio.file.Paths;
import java.util.ArrayList;
import java.util.List;
@@ -159,4 +160,27 @@ public void testListFiles() throws IOException {
assertThat(got).containsExactlyElementsIn(goodPaths);
}
}
+
+ @Test
+ public void testMatcher() throws IOException {
+ try (FileSystem fs = CloudStorageFileSystem.forBucket("bucket")) {
+ String pattern1 = "glob:*.java";
+ PathMatcher javaFileMatcher = fs.getPathMatcher(pattern1);
+ assertMatches(fs, javaFileMatcher, "a.java", true);
+ assertMatches(fs, javaFileMatcher, "a.text", false);
+ assertMatches(fs, javaFileMatcher, "folder/c.java", true);
+ assertMatches(fs, javaFileMatcher, "d", false);
+
+ String pattern2 = "glob:*.{java,text}";
+ PathMatcher javaAndTextFileMatcher = fs.getPathMatcher(pattern2);
+ assertMatches(fs, javaAndTextFileMatcher, "a.java", true);
+ assertMatches(fs, javaAndTextFileMatcher, "a.text", true);
+ assertMatches(fs, javaAndTextFileMatcher, "folder/c.java", true);
+ assertMatches(fs, javaAndTextFileMatcher, "d", false);
+ }
+ }
+
+ private void assertMatches(FileSystem fs, PathMatcher matcher, String toMatch, boolean expected) {
+ assertThat(matcher.matches(fs.getPath(toMatch).getFileName())).isEqualTo(expected);
+ }
}