algolia/algoliasearch-client-java

Invalid duration exception on calculating request timeout

aron9609 opened this issue · 1 comments

  • Algolia Client Version: 3.16.6
  • Language Version: Java

Description

Hey,
We implemented a service, that polls messages from a Kafka topic, and after a data transformation it writes them to our Algolia indices.
It uses BatchOperations, so for writing data our implementation calls the multipleBatchAsync method on the SearchClient.
The integration works mostly well, but sometimes we are experiencing a really strange issue.
We use to have this kind of exceptions in our monitoring system: "IllegalArgumentException (Invalid duration: PT-50H-39M-27.552S)", what is pretty strange, because the SDK tries to use a negative value as request timeout. (Please find the stack trace attached.)

After a short investigation, our best assumption is that the issue occurs, when the Java SDK (HttpTransport::executeWithRetry) retries the request, because of a timeout.
In this case it increases the timeout on the request, that is stored in an int field on the corresponding HttpRequest object.
During the further steps the logic tries to convert this int field to a Duration object, and that is the point, where the issue comes up, as you can see in the attached stack trace.

So our assumption is, that the int value can overflow if we have too many retries.

Our assumption may not be correct, but could you please check it, and help us solving our issue?
Thanks.
algolia_stacktrace_230504.txt

Nice, tthank you for taking care of it. ;)