[
https://issues.apache.org/jira/browse/OLINGO-999?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15476194#comment-15476194
]
Sagar commented on OLINGO-999:
------------------------------
Hi Christian,
Thanks for looking into this issue. As per my latest understanding usage of
Piped..Stream is as designed. I think Piped...Stream is used for optimal usage
of resources (memory) and this way client can push the large batch payloads
without having out of memory issue.
So I found the workaround for my usage.
In our code we did not wanted to use the builtin HTTP transport used by Olingo,
hence we had changed the ODataClient configuration and added own dummy
custom executor service. See below code:
client.getConfiguration().setExecutor(new CustomExecutorService());
In our code we have added a separate thread (BatchPipeReader ) to read the
PipedInputStream
BatchManager payloadManager = batchRequest.payloadManager();
BufferedInputStream pipeIn = new BufferedInputStream(payloadManager.getBody());
// pass batch manager pipedinputstream & bufferedoutputstream to the reader
thread
BatchPipeReader reader = new BatchPipeReader(pipeIn, buffOut);
reader.start();
Now with above code change, changeset is not getting blocked and we were also
able to skip the olingo builtin HTTP transport as well.
I guess Olingo original code/design is fine and we had to modify client side
configuration and executor to meet our use case.
Thanks a lots for your time. I really appreciate it.
I think you can close this ticket for now.
Thanks,
Sagar
> Cannot add more than one request into ChangSet - thread halts in infinite loop
> ------------------------------------------------------------------------------
>
> Key: OLINGO-999
> URL: https://issues.apache.org/jira/browse/OLINGO-999
> Project: Olingo
> Issue Type: Bug
> Components: odata4-client, odata4-commons
> Affects Versions: (Java) V4 4.2.0
> Reporter: Punith DG
> Priority: Blocker
> Labels: batch, changeset, thread-safety
> Attachments: $metadata.xml, BatchTest.java, blocking1.png,
> blocking2.png
>
>
> I am not able to add more than one request to a batch ChangeSet as the
> BatchManager has PipedOutputStream Writer that's causing thread to get into
> infinite loop.
> Check the below sample code in which I'm trying to add requests.
> for loop{
> ODataBatchRequest batchRequest =
> client.getBatchRequestFactory().getBatchRequest("serviceRootURI");
> BatchManager payloadManager = batchRequest.payloadManager();
> ODataChangeset changeset = payloadManager.addChangeset();
> ODataEntityCreateRequest<ClientEntity> createRequest =
> client.getCUDRequestFactory()
>
> .getEntityCreateRequest(new URI("serviceRoot"), clientEntity);
> createRequest.setFormat(ContentType.JSON);
> changeset.addRequest(createRequest); // here the thread waits in infinite
> loop due to piped streams sync problem.
> }
> The problem is observed in line "request.batch(req,
> String.valueOf(contentId));" in addRequest() method of ODataChangesetImpl
> class.
> It seems a known issue in Java -
> http://stackoverflow.com/questions/9171632/piped-input-stream-is-getting-locked
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)