Uploaded image for project: 'jclouds'
  1. jclouds
  2. JCLOUDS-1581

NullPointerException when parsing Cors object for GCE list buckets request

    XMLWordPrintableJSON

Details

    Description

      NullPointerException is thrown when requesting GoogleCloudStorageBlobStore.list for specific buckets.

      Stack trace:

      java.lang.NullPointerException: Null maxAgeSeconds
      	at org.jclouds.googlecloudstorage.domain.AutoValue_Bucket_Cors.<init>(AutoValue_Bucket_Cors.java:33)
      	at org.jclouds.googlecloudstorage.domain.Bucket$Cors.create(Bucket.java:52)
      	at jdk.internal.reflect.GeneratedMethodAccessor188.invoke(Unknown Source)
      	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      	at java.base/java.lang.reflect.Method.invoke(Method.java:566)
      	at com.google.common.reflect.Invokable$MethodInvokable.invokeInternal(Invokable.java:200)
      	at com.google.common.reflect.Invokable.invoke(Invokable.java:101)
      	at org.jclouds.json.internal.DeserializationConstructorAndReflectiveTypeAdapterFactory$DeserializeIntoParameterizedConstructor.newInstance(DeserializationConstructorAndReflectiveTypeAdapterFactory.java:227)
      	at org.jclouds.json.internal.DeserializationConstructorAndReflectiveTypeAdapterFactory$DeserializeIntoParameterizedConstructor.read(DeserializationConstructorAndReflectiveTypeAdapterFactory.java:207)
      	at org.jclouds.json.internal.NullFilteringTypeAdapterFactories$IterableTypeAdapter.readAndBuild(NullFilteringTypeAdapterFactories.java:96)
      	at org.jclouds.json.internal.NullFilteringTypeAdapterFactories$IterableTypeAdapter.read(NullFilteringTypeAdapterFactories.java:84)
      	at org.jclouds.json.internal.NullFilteringTypeAdapterFactories$IterableTypeAdapter.read(NullFilteringTypeAdapterFactories.java:63)
      	at org.jclouds.json.internal.DeserializationConstructorAndReflectiveTypeAdapterFactory$ParameterReader.read(DeserializationConstructorAndReflectiveTypeAdapterFactory.java:275)
      	at org.jclouds.json.internal.DeserializationConstructorAndReflectiveTypeAdapterFactory$DeserializeIntoParameterizedConstructor.read(DeserializationConstructorAndReflectiveTypeAdapterFactory.java:187)
      	at org.jclouds.googlecloud.config.ListPageAdapterFactory$ListPageAdapter.readItems(ListPageAdapterFactory.java:73)
      	at org.jclouds.googlecloud.config.ListPageAdapterFactory$ListPageAdapter.read(ListPageAdapterFactory.java:56)
      	at org.jclouds.googlecloud.config.ListPageAdapterFactory$ListPageAdapter.read(ListPageAdapterFactory.java:36)
      	at com.google.gson.Gson.fromJson(Gson.java:932)
      	at com.google.gson.Gson.fromJson(Gson.java:897)
      	at org.jclouds.json.internal.GsonWrapper.fromJson(GsonWrapper.java:56)
      	at org.jclouds.http.functions.ParseJson.apply(ParseJson.java:83)
      	at org.jclouds.http.functions.ParseJson.apply(ParseJson.java:77)
      	at org.jclouds.http.functions.ParseJson.apply(ParseJson.java:62)
      	at org.jclouds.http.functions.ParseJson.apply(ParseJson.java:42)
      	at org.jclouds.rest.internal.InvokeHttpMethod.invoke(InvokeHttpMethod.java:91)
      	at org.jclouds.rest.internal.InvokeHttpMethod.apply(InvokeHttpMethod.java:74)
      	at org.jclouds.rest.internal.InvokeHttpMethod.apply(InvokeHttpMethod.java:45)
      	at org.jclouds.reflect.FunctionalReflection$FunctionalInvocationHandler.handleInvocation(FunctionalReflection.java:117)
      	at com.google.common.reflect.AbstractInvocationHandler.invoke(AbstractInvocationHandler.java:86)
      	at com.sun.proxy.$Proxy231.listBucket(Unknown Source)
      	at org.jclouds.googlecloudstorage.blobstore.GoogleCloudStorageBlobStore.list(GoogleCloudStorageBlobStore.java:119) 

       

      Bucket that is causing exception has following configuration (i removed ids from json):

      
          {
            "kind": "storage#bucket",
            "selfLink": "",
            "id": "",
            "name": "",
            "projectNumber": "",
            "metageneration": "1",
            "location": "US-CENTRAL1",
            "storageClass": "STANDARD",
            "etag": "CAE=",
            "timeCreated": "2020-10-26T13:54:23.835Z",
            "updated": "2020-10-26T13:54:23.835Z",
            "cors": [
              {
                "origin": [
                  "https://*.cloud.google.com",
                  "https://*.corp.google.com",
                  "https://*.corp.google.com:*"
                ],
                "method": [
                  "GET"
                ]
              }
            ],
            "iamConfiguration": {
              "bucketPolicyOnly": {
                "enabled": true,
                "lockedTime": "2021-01-24T13:54:23.835Z"
              },
              "uniformBucketLevelAccess": {
                "enabled": true,
                "lockedTime": "2021-01-24T13:54:23.835Z"
              },
              "publicAccessPrevention": "unspecified"
            },
            "locationType": "region"
          } 

      As you can see the CORS object have no maxAgeSeconds field. This is consistent with documentation (https://cloud.google.com/storage/docs/cross-origin#cors-elements) where maxAgeSeconds is described as optional.

      Attachments

        Activity

          People

            gaul Andrew Gaul
            lukaszrek Lukasz Rek
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Time Tracking

                Estimated:
                Original Estimate - Not Specified
                Not Specified
                Remaining:
                Remaining Estimate - 0h
                0h
                Logged:
                Time Spent - 20m
                20m