问题描述
我正在尝试使用 GetAllRequestBuilder
从上游 odata 服务读取大约 390 万条记录。该代码将 pageSize 设置为 5000,并使用 HttpDestination
的实例从上游服务读取数据。
执行的确切代码段:
CompletableFuture.runAsync(() ->{
// initial setup code for destination
Stream<Product> stream = new DefaultProductService()
.getAllProduct()
.withPreferredPageSize(5000)
.streamingEntities()
.execute(sourceDestination);
// ...
stream.peek(entry -> {log.info("entry: " + entry.toString());})
.forEach(entry -> publishOnEventBus(entry));
});
过了一会儿,我收到了 ODATADeserializationException
。我无法分享确切的堆栈跟踪,但在堆栈跟踪中我看到 Caused by: com.google.gson.JsonIOException: java.io.IOException: Stream closed
。
异常在类 httpentityReader
中抛出。
"com.sap.cloud.sdk.datamodel.odata.client.exception.ODataDeserializationException: A problem occurred while streaming the OData response.","tat com.sap.cloud.sdk.datamodel.odata.client.request.httpentityReader.lambda$stream$0(httpentityReader.java:121)"
这突然发生,在多次运行期间,有时读取 66k 记录,有时是 400k,有时是 14k。
注意:我们使用 com.sap.cloud.sdk.datamodel
来生成服务类。我们使用返回 getAllProduct
的 GetAllRequestBuilder
。 execute 方法本身返回反序列化的实体。
我可以做些什么来确保不会发生此异常并且流继续读取到最后?我们使用的是 sap-cloud-sdk
版本 3.48.0
。
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)