简体   繁体   English

从Google储存区读取时com.google.api.client.googleapis.json.GoogleJsonResponseException

[英]com.google.api.client.googleapis.json.GoogleJsonResponseException while reading from google bucket

I am trying to list all the files from one directory in google bucket and reading data from each file, for some buckets it is working but for one bucket it is throwing error 我正在尝试列出Google存储桶中一个目录中的所有文件,并从每个文件中读取数据,某些存储桶正在工作,但有一个存储桶则抛出错误

Caused by: com.google.api.client.googleapis.json.GoogleJsonResponseException: 500 Internal Server Error { "code" : 500, "errors" : [ { "domain" : "global", "message" : "Internal Error", "reason" : "responseTooLarge" } ], "message" : "Internal Error" 引起原因:com.google.api.client.googleapis.json.GoogleJsonResponseException:500内部服务器错误{“代码”:500,“错误”:[{“域”:“全局”,“消息”:“内部错误” ,“ reason”:“ responseTooLarge”}],“ message”:“内部错误”

stacktrace: Exception in thread "main" com.google.cloud.storage.StorageException: Internal Error at com.google.cloud.storage.spi.v1.HttpStorageRpc.translate(HttpStorageRpc.java:220) at com.google.cloud.storage.spi.v1.HttpStorageRpc.list(HttpStorageRpc.java:346) at com.google.cloud.storage.StorageImpl$8.call(StorageImpl.java:299) at com.google.cloud.storage.StorageImpl$8.call(StorageImpl.java:296) at com.google.api.gax.retrying.DirectRetryingExecutor.submit( at com.google.cloud.RetryHelper.run(RetryHelper.java:74) at com.google.cloud.RetryHelper.runWithRetries(RetryHelper.java:51) at com.google.cloud.storage.StorageImpl.listBlobs(StorageImpl.java:295) at com.google.cloud.storage.StorageImpl.list(StorageImpl.java:262) at WriteToGs.main(WriteToGs.java:22) stacktrace:线程“ main”中的异常com.google.cloud.storage.StorageException:com.google.cloud处com.google.cloud.storage.spi.v1.HttpStorageRpc.translate(HttpStorageRpc.java:220)处的内部错误。 storage.spi.v1.HttpStorageRpc.list(HttpStorageRpc.java:346)位于com.google.cloud.storage.StorageImpl $ 8.call(StorageImpl.java:299)位于com.google.cloud.storage.StorageImpl $ 8.call( com.google.api.gax.retrying.DirectRetryingExecutor.submit(com.google.cloud.RetryHelper.run(RetryHelper.java:74)处的StorageImpl.java:296)com.google.cloud.RetryHelper.runWithRetries(RetryHelper) .java:51),位于com.google.cloud.storage.StorageImpl.listBlobs(StorageImpl.java:295),位于com.google.cloud.storage.StorageImpl.list(StorageImpl.java:262),位于WriteToGs.main(WriteToGs)。 Java的:22)

import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;


public class WriteToGs {
    static PGPContainer pgpContainer = new PGPContainer();
    final static Storage storage = StorageOptions.getDefaultInstance().getService();
    public static void main(String[] args) throws Exception {
        final DateFormat dateFormat = new SimpleDateFormat("yyyyMMddHHmm");
        final Date date = new Date();
        final String destinationDirectory=args[2];
        final String flowname=args[3];

        final String num_threads=args[4];

        Iterable<Blob> blobs = storage.list(args[0], Storage.BlobListOption.prefix(args[1])).iterateAll();
        ExecutorService executorService = Executors.newFixedThreadPool(Integer.parseInt(num_threads));
        for (Blob blob : blobs) {
            System.out.println("Blob name:"+blob.getName());
            final String destinationFilename=blob.getName();
            final Blob contentBlob=blob;

            executorService.execute(new Runnable() {
                public void run() {
                    String fileContent = new String(contentBlob.getContent());
                    BlobId newblobId = BlobId.of(destinationDirectory,"xyz/fds" + flowname + "/"
                            + dateFormat.format(date) + "/" + destinationFilename.replace(".txt",".pgp"));
                    BlobInfo blobInfo = BlobInfo.newBuilder(newblobId).setContentType("text/plain").build();
                    try {

                        System.out.println("Blob name deleted:"+contentBlob.getName());
                        storage.delete(contentBlob.getBlobId());
                    } catch (Exception e) {
                        e.printStackTrace();
                    }




                }
            });
        }
        executorService.shutdown();
    }

}

Well, assuming that the line 22 (which is where the error came from) is the one: 好吧,假设第22行(​​错误的出处)就是其中之一:

System.out.println("Blob name:"+blob.getName());

Probably, the property “name” inside blob is large enough to break the application. blob中的属性“ name”可能足够大,足以破坏应用程序。 But I'm almost sure this is not the line where the application is being broken. 但是我几乎可以确定这不是应用程序中断的地方。

Based on a similar question, GoogleJsonResponseException: 500 Internal Server Error : Response Too Large To Return , I suggest you to create a bug, since this could be a problem directly related with Google libraries. 基于类似的问题, GoogleJsonResponseException:500内部服务器错误:响应太大而无法返回 ,我建议您创建一个错误,因为这可能是与Google库直接相关的问题。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 com.google.api.client.googleapis.json.GoogleJsonResponseException: 403 Forbidden - com.google.api.client.googleapis.json.GoogleJsonResponseException: 403 Forbidden Google Admob API - Java 客户端 - com.google.api.client.googleapis.json.GoogleJsonResponseException: 403 Forbidden - Google Admob API - Java client - com.google.api.client.googleapis.json.GoogleJsonResponseException: 403 Forbidden com.google.api.client.googleapis.json.GoogleJsonResponseException:400错误的请求 - com.google.api.client.googleapis.json.GoogleJsonResponseException: 400 Bad Request java.lang.IllegalAccessError:尝试访问字段com.google.api.client.googleapis.GoogleHeaders.userAgent - java.lang.IllegalAccessError: tried to access field com.google.api.client.googleapis.GoogleHeaders.userAgent java.lang.ClassNotFoundException:com.google.api.client.googleapis.auth.oauth2.GoogleIdTokenVerifier$Builder - java.lang.ClassNotFoundException: com.google.api.client.googleapis.auth.oauth2.GoogleIdTokenVerifier$Builder com.google.api.client.googleapis.auth.oauth2.GoogleCredential 现已弃用 - com.google.api.client.googleapis.auth.oauth2.GoogleCredential is now deprecated Caused by: com.google.api.client.http.HttpResponseException: 400 Bad Request POST https://oauth2.googleapis.com/token - Caused by: com.google.api.client.http.HttpResponseException: 400 Bad Request POST https://oauth2.googleapis.com/token Google Reseller API收到GoogleJsonResponseException:禁止使用403 - Google Reseller API getting GoogleJsonResponseException: 403 Forbidden 从Google Maps API读取JSON字符串 - Reading a JSON String from Google Maps API com.google.api.client.json.GenericJson的GWT仿真 - GWT emulation for com.google.api.client.json.GenericJson
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM