broadinstitute / gatk

Official code repository for GATK versions 4 and up
https://software.broadinstitute.org/gatk
Other
1.7k stars 591 forks source link

Paths.get throws exception if default Google project isn't set #2707

Open lbergelson opened 7 years ago

lbergelson commented 7 years ago
BucketUtils.isCloudStorageUrl(Paths.get(URI.create("gs://abucket/bucket")))

throws

java.lang.IllegalArgumentException: A project ID is required for this service but could not be determined from the builder or the environment.  Please set a project ID using the builder.

    at shaded.cloud_nio.com.google.common.base.Preconditions.checkArgument(Preconditions.java:122)
    at com.google.cloud.ServiceOptions.<init>(ServiceOptions.java:248)
    at com.google.cloud.storage.StorageOptions.<init>(StorageOptions.java:82)
    at com.google.cloud.storage.StorageOptions.<init>(StorageOptions.java:30)
    at com.google.cloud.storage.StorageOptions$Builder.build(StorageOptions.java:77)
    at com.google.cloud.storage.StorageOptions.getDefaultInstance(StorageOptions.java:121)
    at com.google.cloud.storage.contrib.nio.CloudStorageFileSystemProvider.initStorage(CloudStorageFileSystemProvider.java:153)
    at com.google.cloud.storage.contrib.nio.CloudStorageFileSystemProvider.getPath(CloudStorageFileSystemProvider.java:208)
    at com.google.cloud.storage.contrib.nio.CloudStorageFileSystemProvider.getPath(CloudStorageFileSystemProvider.java:85)
    at java.nio.file.Paths.get(Paths.java:143)
    at org.broadinstitute.hellbender.utils.gcs.BucketUtilsTest.testNoIllegalArgumentException(BucketUtilsTest.java:38)
    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:108)
    at org.testng.internal.Invoker.invokeMethod(Invoker.java:661)
    at org.testng.internal.Invoker.invokeTestMethod(Invoker.java:869)
    at org.testng.internal.Invoker.invokeTestMethods(Invoker.java:1193)
    at org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:126)
    at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:109)
    at org.testng.TestRunner.privateRun(TestRunner.java:744)
    at org.testng.TestRunner.run(TestRunner.java:602)
    at org.testng.SuiteRunner.runTest(SuiteRunner.java:380)
    at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:375)
    at org.testng.SuiteRunner.privateRun(SuiteRunner.java:340)
    at org.testng.SuiteRunner.run(SuiteRunner.java:289)
    at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:52)
    at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:86)
    at org.testng.TestNG.runSuitesSequentially(TestNG.java:1301)
    at org.testng.TestNG.runSuitesLocally(TestNG.java:1226)
    at org.testng.TestNG.runSuites(TestNG.java:1144)
    at org.testng.TestNG.run(TestNG.java:1115)
    at org.testng.IDEARemoteTestNG.run(IDEARemoteTestNG.java:72)
    at org.testng.RemoteTestNGStarter.main(RemoteTestNGStarter.java:127)

This should be a safe method to call. We should either refactor this method or we change NIO to not throw in this case.

droazen commented 7 years ago

Best way to fix this is via https://github.com/broadinstitute/gatk/issues/958

jean-philippe-martin commented 7 years ago

Note that the bug title is a bit misleading: is says "BucketUtils.isCloudStorageUrl throws" but the exception is actually thrown upstream, at Paths.get. So nothing we do in BucketUtils can fix that.

jean-philippe-martin commented 7 years ago

It turns out we can edit issue titles! I changed it to remove the potential confusion.

jean-philippe-martin commented 7 years ago

Note that we have a workaround (to the problem as initially described): instead of

BucketUtils.isCloudStorageUrl(Paths.get(URI.create("gs://abucket/bucket")))

You can use:

BucketUtils.isCloudStorageUrl("gs://abucket/bucket")