Skip to content

NPE when creating a Path with a bucket that doesn't exist. #857

Closed
@lbergelson

Description

Paths.get(new Uri(A_PATH_TO_A_BUCKET_THAT_DOESNT_EXIST)) crashes with a NullPointerException if autoDetectRequesterPays = true.

Environment details

  1. cloud nio
  2. OS type and version: all
  3. Java version: all
  4. version(s): current and probably previous

Steps to reproduce

  1. autoDetectRequesterPays = true
  2. Create a path to a gs://bucket that doesn't exist
  3. 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)
	

Metadata

Assignees

Labels

api: storageIssues related to the googleapis/java-storage-nio API.status: investigatingThe issue is under investigation, which is determined to be non-trivial.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions