Google cloud storage 执行对象下载时出现Google存储JSON API NullPointException

Google cloud storage 执行对象下载时出现Google存储JSON API NullPointException,google-cloud-storage,Google Cloud Storage,当我尝试使用以下代码下载存储对象时,我遇到了NullPointException: Storage.Objects.Get getObject = storage.objects().get(BUCKET_LOG, entity); getObject.getMediaHttpDownloader().setDirectDownloadEnabled(true);//directly download, which is recommended for non AppEngine

当我尝试使用以下代码下载存储对象时,我遇到了NullPointException:

    Storage.Objects.Get getObject = storage.objects().get(BUCKET_LOG, entity);
    getObject.getMediaHttpDownloader().setDirectDownloadEnabled(true);//directly download, which is recommended for non AppEngine Apps.
堆栈跟踪是:
com.google.api.client.googleapis.media.mediahtttpdownloader.download(mediahtttpdownloader.java:186)
在com.google.api.client.googleapis.services.AbstractGoogleClientRequest.ExecuteMedia上下载到(AbstractGoogleClientRequest.java:553)
在com.google.api.services.storage.storage$Objects$Get.executeMediaAndDownloadTo(storage.java:4606)
在com.alibaba.intl.google.adwords.util.GoogleStorageUtil.downloadStorageObject(GoogleStorageUtil.java:149)

因此,我查看了MediaHttpDownloader的第186行,发现:

    mediaContentLength = response.getHeaders().getContentLength();
好的,问题是,方法getContentLength可能返回
null
值,而变量
mediaContentLength
的类型是long,但不是long

HttpHeaders的快照片段:

   public final Long getContentLength() {
       return getFirstHeaderValue(contentLength);
   }

   /**Returns the first header value based on the given internal list value.*/
   private <T> T getFirstHeaderValue(List<T> internalValue) {
       return internalValue == null ? null : internalValue.get(0);
   }
public final Long getContentLength(){
返回getFirstHeaderValue(contentLength);
}
/**基于给定的内部列表值返回第一个标题值*/
私有T getFirstHeaderValue(列出内部值){
返回internalValue==null?null:internalValue.get(0);
}

我正在使用AdWords API V201402的Java库。

看起来像个bug。如果删除对setDirectDownloadEnabled()的调用,还会发生这种情况吗?谢谢您的回复,Brandon。更改为setDirectDownloadEnabled(false)后,错误消失了。所以我猜这是一个直接下载的bug,如果我们在中继中下载媒体应该没问题。但由于直接下载是非AppEngine应用程序的推荐方式,我希望能够解决这个问题。再次感谢。