eclipse-ee4j / eclipse-ee4j/jersey

Setting cookies in ContainerResponseContext removes existing cookies in HttpServletResponse

Open
#3,282 4 comments 0 reactions 0 assignees View on GitHub
Component: core Priority: Major Type: Bug
Dominant language
Java
Stars
730
Forks
382
PR merge metrics
No merged PRs in 30d

Description

Looks like if cookie is added using ContainerResponseContext it removes all cookies already added directly HttpServletResponse.

If we create new session using HttpServletRequest.getSession(), it should add Set-Cookie header to HttpServletResponse, which it does. However I have a ContainerResponseFilter which may beed to add some cookies. If I add cookie using

```
containerResponseContext.getHeaders().add(HttpHeaders.SET_COOKIE, new NewCookie(...));
```

, the Set-Cookie header for session cookie in HttpServletResponse is never sent to client.

I'm not sure if that's the proper way add cookies in Jersey, but at least the behaviour seems a bit strange.
#### Affected Versions
[2.22.1]

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.