NPE when creating a Path with a bucket that doesn't exist. #857
Closed
Description
Paths.get(new Uri(A_PATH_TO_A_BUCKET_THAT_DOESNT_EXIST))
crashes with a NullPointerException if autoDetectRequesterPays
= true.
Environment details
- cloud nio
- OS type and version: all
- Java version: all
- version(s): current and probably previous
Steps to reproduce
- autoDetectRequesterPays = true
- Create a path to a gs://bucket that doesn't exist
- NPE
Code example
public void testBucketDoesntExist() throws IOException, URISyntaxException {
CloudStorageConfiguration config = CloudStorageConfiguration.builder()
.autoDetectRequesterPays(true)
.userProject(YOUR_PROJECT_NAME)
.build();
CloudStorageFileSystemProvider.setDefaultCloudStorageConfiguration(config);
Paths.get(new URI("gs://abuckethatdoesntexist"));
}
Stack trace
java.lang.NullPointerException
at com.google.cloud.storage.contrib.nio.CloudStorageFileSystemProvider.requesterPays(CloudStorageFileSystemProvider.java:967)
at com.google.cloud.storage.contrib.nio.CloudStorageFileSystem.<init>(CloudStorageFileSystem.java:209)
at com.google.cloud.storage.contrib.nio.CloudStorageFileSystemProvider.newFileSystem(CloudStorageFileSystemProvider.java:263)
at com.google.cloud.storage.contrib.nio.CloudStorageFileSystemProvider.getFileSystem(CloudStorageFileSystemProvider.java:225)
at com.google.cloud.storage.contrib.nio.CloudStorageFileSystemProvider.getPath(CloudStorageFileSystemProvider.java:271)
at com.google.cloud.storage.contrib.nio.CloudStorageFileSystemProvider.getPath(CloudStorageFileSystemProvider.java:86)
at java.nio.file.Paths.get(Paths.java:143)
at org.broadinstitute.hellbender.utils.gcs.BucketUtilsUnitTest.testBucketDoesntExist(BucketUtilsUnitTest.java:351)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:133)
at org.testng.internal.TestInvoker.invokeMethod(TestInvoker.java:584)
at org.testng.internal.TestInvoker.invokeTestMethod(TestInvoker.java:172)
at org.testng.internal.MethodRunner.runInSequence(MethodRunner.java:46)
at org.testng.internal.TestInvoker$MethodInvocationAgent.invoke(TestInvoker.java:804)
at org.testng.internal.TestInvoker.invokeTestMethods(TestInvoker.java:145)
at org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:146)
at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:128)