Details

      Description

      Reported initially at https://github.com/quarkusio/quarkus/issues/8795:

      In endpoints returning an async stream mapped to SSE, we push the context but never pop it, thus resulting in a growing number of context objects. We never notice it because we don't use an API that throws if there are too many contexts, but some other parts of the API (the client proxy) does and will throw at the 20th SSE element.

      ```java
      @GET
      @Path("sse")
      @Produces(MediaType.SERVER_SENT_EVENTS)
      public Publisher<String> sse() {
      return Flowable.create(source ->{
      for(int i=0;i<30;i++)

      { source.onNext(i+"-"+ResteasyContext.getContextDataLevelCount()); }

      source.onComplete();
      }, BackpressureStrategy.BUFFER);
      }
      ```

      This will show the issue, where you can see `getContextDataLevelCount` grow on each SSE element.

      I've a PR incoming with a fix for this and the raw/collected async stream variants too, plus several other locations I found in the code that might be problematic, using the newer `ResteasyContext.addCloseableContextDataLevel()` API.

        Gliffy Diagrams

          Attachments

            Activity

              People

              • Assignee:
                FroMage Stephane Epardaud
                Reporter:
                FroMage Stephane Epardaud
              • Votes:
                0 Vote for this issue
                Watchers:
                3 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: