Uploaded image for project: 'Hibernate Search'
  1. HSEARCH-2854

IllegalStateException when sending an Elasticsearch request with a content-length

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 5.8.0.CR1
    • Fix Version/s: 5.8.0.Final
    • Component/s: backend-elasticsearch
    • Labels:
      None

      Description

      When content-length is defined, the encoder is a LengthDelimitedEncoder, and even a 0-length write will trigger an exception when the content length has been reached.
      The current code allows 0-length writes, and we should protect ourselves against that.

      Note: this problem only affects 5.8.0.CR1, but was only witnessed while working on HSEARCH-2849 Closed . It is possible that the bug never actually happens in 5.8.0.CR1 because HSEARCH-2849 Closed makes it content-length definition rarer.

              at org.hibernate.search.elasticsearch.work.impl.BulkWork.lambda$execute$1(BulkWork.java:75)
              at org.hibernate.search.util.impl.Futures.lambda$handler$1(Futures.java:57)
              at java.util.concurrent.CompletableFuture.uniExceptionally(CompletableFuture.java:870)
              at java.util.concurrent.CompletableFuture$UniExceptionally.tryFire(CompletableFuture.java:852)
              at java.util.concurrent.CompletableFuture.postComplete(CompletableFuture.java:474)
              at java.util.concurrent.CompletableFuture.completeExceptionally(CompletableFuture.java:1977)
              at org.hibernate.search.elasticsearch.client.impl.DefaultElasticsearchClient$1.onFailure(DefaultElasticsearchClient.java:108)
              at org.elasticsearch.client.RestClient$FailureTrackingResponseListener.onDefinitiveFailure(RestClient.java:605)
              at org.elasticsearch.client.RestClient$1.retryIfPossible(RestClient.java:396)
              at org.elasticsearch.client.RestClient$1.failed(RestClient.java:375)
              at org.apache.http.concurrent.BasicFuture.failed(BasicFuture.java:134)
              at org.apache.http.impl.nio.client.AbstractClientExchangeHandler.failed(AbstractClientExchangeHandler.java:419)
              at org.apache.http.nio.protocol.HttpAsyncRequestExecutor.exception(HttpAsyncRequestExecutor.java:155)
              at org.apache.http.impl.nio.DefaultNHttpClientConnection.produceOutput(DefaultNHttpClientConnection.java:310)
              at org.apache.http.impl.nio.client.InternalIODispatch.onOutputReady(InternalIODispatch.java:86)
              at org.apache.http.impl.nio.client.InternalIODispatch.onOutputReady(InternalIODispatch.java:39)
              at org.apache.http.impl.nio.reactor.AbstractIODispatch.outputReady(AbstractIODispatch.java:152)
              at org.apache.http.impl.nio.reactor.BaseIOReactor.writable(BaseIOReactor.java:188)
              at org.apache.http.impl.nio.reactor.AbstractIOReactor.processEvent(AbstractIOReactor.java:341)
              at org.apache.http.impl.nio.reactor.AbstractIOReactor.processEvents(AbstractIOReactor.java:315)
              at org.apache.http.impl.nio.reactor.AbstractIOReactor.execute(AbstractIOReactor.java:276)
              at org.apache.http.impl.nio.reactor.BaseIOReactor.execute(BaseIOReactor.java:104)
              at org.apache.http.impl.nio.reactor.AbstractMultiworkerIOReactor$Worker.run(AbstractMultiworkerIOReactor.java:588)
              at java.lang.Thread.run(Thread.java:745)
      Caused by: java.lang.IllegalStateException: Encoding process already completed
              at org.apache.http.util.Asserts.check(Asserts.java:34)
              at org.apache.http.impl.nio.codecs.AbstractContentEncoder.assertNotCompleted(AbstractContentEncoder.java:89)
              at org.apache.http.impl.nio.codecs.LengthDelimitedEncoder.write(LengthDelimitedEncoder.java:102)
              at org.hibernate.search.elasticsearch.util.impl.GsonHttpEntity$ProgressiveCharBufferWriter.fullyWrite(GsonHttpEntity.java:435)
              at org.hibernate.search.elasticsearch.util.impl.GsonHttpEntity$ProgressiveCharBufferWriter.flushCurrentBuffer(GsonHttpEntity.java:420)
              at org.hibernate.search.elasticsearch.util.impl.GsonHttpEntity$ProgressiveCharBufferWriter.attemptFlushPendingBuffers(GsonHttpEntity.java:361)
              at org.hibernate.search.elasticsearch.util.impl.GsonHttpEntity$ProgressiveCharBufferWriter.flushToOutput(GsonHttpEntity.java:453)
              at org.hibernate.search.elasticsearch.util.impl.GsonHttpEntity.produceContent(GsonHttpEntity.java:274)
              at org.apache.http.nio.protocol.BasicAsyncRequestProducer.produceContent(BasicAsyncRequestProducer.java:125)
              at org.apache.http.impl.nio.client.MainClientExec.produceContent(MainClientExec.java:262)
              at org.apache.http.impl.nio.client.DefaultClientExchangeHandlerImpl.produceContent(DefaultClientExchangeHandlerImpl.java:136)
              at org.apache.http.nio.protocol.HttpAsyncRequestExecutor.outputReady(HttpAsyncRequestExecutor.java:241)
              at org.apache.http.impl.nio.DefaultNHttpClientConnection.produceOutput(DefaultNHttpClientConnection.java:290)
              ... 10 more
      

        Attachments

          Issue links

            Activity

              People

              • Assignee:
                yrodiere Yoann Rodière
                Reporter:
                yrodiere Yoann Rodière
              • Votes:
                0 Vote for this issue
                Watchers:
                1 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: