Resteasy does not set Expires attribute for JAX-RS NewCookie correctly in EAP 7

Solution Unverified - Updated -

Issue

Resteasy does not set Expires attribute correctly when testing the following JAX-RS application using javax.ws.rs.core.NewCookie to set Expires attribute to current date:

    @GET
    @Path("get0")
    public Response get0() {
        System.out.println("MyEndpoint get0 - Version 0 Cookie");
        NewCookie cookie = new NewCookie("Name", "Value", "/", "*", 0, "comment", 3600, new Date(),
                true, true);
        return Response.ok().cookie(cookie).entity(cookie.toString()).build();
    }  

    @GET
    @Path("get1")
    public Response get1() {
        System.out.println("MyEndpoint get1 - Version 1 Cookie");
        NewCookie cookie = new NewCookie("Name", "Value", "/", "*", 1, "comment", 3600, new Date(),
                true, true);
        return Response.ok().cookie(cookie).entity(cookie.toString()).build();
    }  

V0 Cookie set Expires attribute but it's not same to a specified time (current date). It looks calculated from Max-Age attribute:

$ curl -v localhost:8080/myapp/rest/get0
> GET /myapp/rs/get0 HTTP/1.1
> ...
>
< HTTP/1.1 200 OK
< ...
< Set-Cookie: Name=Value; path=/; domain=*; secure; HttpOnly; Max-Age=3600; Expires=Mon, 22-Aug-2016 01:12:52 GMT
< ...
< Date: Mon, 22 Aug 2016 00:12:52 GMT
<
...

V1 Cookie does not set Expires attribute:

$ curl -v localhost:8080/myapp/rest/get1
> GET /myapp/rs/get1 HTTP/1.1
> ...
>
< HTTP/1.1 200 OK
< ...
< Set-Cookie: Name=Value; Version=1; Path=/; Domain=*; Secure; HttpOnly; Max-Age=3600
< ...
< Date: Mon, 22 Aug 2016 00:12:55 GMT
<
...

Environment

  • Red Hat JBoss Enterprise Application Platform (EAP) 7.x
  • JAX-RS / Resteasy

Subscriber exclusive content

A Red Hat subscription provides unlimited access to our knowledgebase, tools, and much more.

Current Customers and Partners

Log in for full access

Log In

New to Red Hat?

Learn more about Red Hat subscriptions

Using a Red Hat product through a public cloud?

How to access this content