Uploaded image for project: 'RESTEasy'
  1. RESTEasy
  2. RESTEASY-2673

Unable to set cookies per request while retaining ResteasyClient reusability

    XMLWordPrintable

Details

    • Bug
    • Resolution: Not a Bug
    • Major
    • 4.7.0.Beta1, 4.7.0.Final
    • 3.9.3.Final
    • jaxrs
    • None
    • Hide
      1. Create an instance of ResteasyClient.
      2. Make a request to a resource that responds with SET-COOKIE header
      3. Make another call to the same resource with the same client. This will result in the previously received cookie being passed on.
      Show
      Create an instance of ResteasyClient. Make a request to a resource that responds with SET-COOKIE header Make another call to the same resource with the same client. This will result in the previously received cookie being passed on.

    Description

      I'm migrating a web  application written for Payara5 to Wildfly 18.

      In my app I use an http client to make requests to Cisco Socialminer API. Since the app has to make these requests often, the client is created only once upon application startup and then is reused indefinitely.

      One of the endpoints that creates a chat session returns a JSESSIONID cookie that is later used to poll for newly created chat session's events. I store the cookie in the database and set it manually when needed.

      This is how I make the request:

      WebTarget target = environment.getClient(false)
         .target(url);
      Response response = target.request()
         .post(Entity.entity(payload, MediaType.APPLICATION_XML));
      

      The first call after application startup works just fine. However, upon receiving a response containing "JSESSIONID" cookie, the client stores the cookie and automatically adds it to the next request that is made with the same client instance.

      This creates a problem, because Socialminer API doesn't expect a JSESSIONID cookie on that request and responds erratically.

      I tried googling for a solution, but only solutions I've found involved rebuilding the client.

      Is there a way to prevent Resteasy from storing the received cookie or at least prevent resteasy from attaching it to the consequent requests?

      Attachments

        1. back-starter.war
          7 kB
        2. back-starter.zip
          7 kB
        3. image-2021-04-15-17-38-18-899.png
          image-2021-04-15-17-38-18-899.png
          33 kB
        4. image-2021-04-15-17-38-29-601.png
          image-2021-04-15-17-38-29-601.png
          155 kB
        5. image-2021-04-19-17-18-55-872.png
          image-2021-04-19-17-18-55-872.png
          137 kB
        6. image-2021-04-21-13-46-53-184.png
          image-2021-04-21-13-46-53-184.png
          158 kB

        Activity

          People

            weli@redhat.com Weinan Li
            a.djaginov Andro Djaginov (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: