微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

Google my business 中线程“main”java.io.EOFException 中的异常

如何解决Google my business 中线程“main”java.io.EOFException 中的异常

我正在编写代码以根据此处描述的内容提取所有位置的见解: https://developers.google.com/my-business/content/insight-data?hl=en 有时(并不总是)在运行代码我有这个异常:

Exception in thread "main" java.io.EOFException
    at java.io.ObjectInputStream$PeekInputStream.readFully(ObjectInputStream.java:2736)
    at java.io.ObjectInputStream$BlockDataInputStream.readShort(ObjectInputStream.java:3211)
    at java.io.ObjectInputStream.readStreamHeader(ObjectInputStream.java:896)
    at java.io.ObjectInputStream.<init>(ObjectInputStream.java:358)
    at com.google.api.client.util.IoUtils.deserialize(IoUtils.java:171)
    at com.google.api.client.util.store.FileDataStoreFactory$FileDataStore.<init>(FileDataStoreFactory.java:102)
    at com.google.api.client.util.store.FileDataStoreFactory.createDataStore(FileDataStoreFactory.java:73)
    at com.google.api.client.util.store.AbstractDataStoreFactory.getDataStore(AbstractDataStoreFactory.java:55)
    at com.google.api.client.auth.oauth2.StoredCredential.getDefaultDataStore(StoredCredential.java:171)
    at com.google.api.client.auth.oauth2.AuthorizationCodeFlow$Builder.setDataStoreFactory(AuthorizationCodeFlow.java:744)
    at com.google.api.client.googleapis.auth.oauth2.GoogleAuthorizationCodeFlow$Builder.setDataStoreFactory(GoogleAuthorizationCodeFlow.java:209)

有谁知道我该如何解决这个问题?错误是否可能是因为我的帐户中有很多位置并且它向 GMB 发送了太多请求?

我尝试分享代码的一些抽象部分:

    JSONObject jObj=new JSONObject();
        ReportLocationInsightsRequest content = new ReportLocationInsightsRequest();
        content.setFactory(JSON_FACTORY);
        BasicmetricsRequest basicRequest = new BasicmetricsRequest();
    
        content.setLocationNames(locationNamelist); // locationNamelist  is provided prevIoUsely in another function 
        List<MetricRequest> metricRequests= new ArrayList<MetricRequest>();
        MetricRequest metricR=new MetricRequest();
        String metric="ALL";
        metricR.setMetric(metric);
        metricRequests.add(metricR);
        timeRange.setStartTime(MyStartTime); // desired start time
        timeRange.setEndTime(MyEndTime); // desired end time
        basicRequest.setTimeRange(timeRange);
        basicRequest.setMetricRequests(metricRequests);
        content.setBasicRequest(basicRequest );
        TimeRange timeRange=new TimeRange();
    
           try {
                    MyBusiness.Accounts.Locations.ReportInsights locationReportInsight= 
                            mybusiness.accounts().locations().reportInsights(accName,content);
                    ReportLocationInsightsResponse response= locationReportInsight.execute();
            
                    jObj=new JSONObject(response);
            
                }catch(Exception e) {
        
                    System.out.println(" Exception "+ e);
            
                }

提前致谢

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。