Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[jakartaee-tck-dev] Incorrect parsing of expiry date in servlet/api/javax_servlet_http/cookie#setMaxAgePositiveTest

Hello all,

When trying to run the servlet test `com.sun.ts.tests.servlet.api.javax_servlet_http.cookie.setMaxAgePositiveTest()`, I am seeing what looks to be a weird parsing error: The expiry date was incorrect, expected =Mon Jul 08 09:21:00 EDT 2019, result = Sat Jul 08 08:21:00 EST 19. The dates appear to be the same but the days are different.

Trace showing request and response:
```
[javatest.batch] 07-08-2019 09:21:40:  [HttpRequest] Dispatching request: 'GET /servlet_jsh_cookie_web/TestServlet?testname=setMaxAgeVer0PositiveTest HTTP/1.1' to target server at 'localhost:9080'
[javatest.batch] 07-08-2019 09:21:40:  TRACE: ########## The real value set: false
[javatest.batch] 07-08-2019 09:21:40:  TRACE: [WIRE] - >> "GET /servlet_jsh_cookie_web/TestServlet?testname=setMaxAgeVer0PositiveTest HTTP/1.1[\r][\n]"
[javatest.batch] 07-08-2019 09:21:40:  TRACE: [WIRE] - >> "User-Agent: Jakarta Commons-HttpClient/3.1[\r][\n]"
[javatest.batch] 07-08-2019 09:21:40:  TRACE: [WIRE] - >> "Host: localhost:9080[\r][\n]"
[javatest.batch] 07-08-2019 09:21:40:  TRACE: [WIRE] - >> "[\r][\n]"
[javatest.batch] 07-08-2019 09:21:40:  TRACE: [WIRE] - << "HTTP/1.1 200 OK[\r][\n]"
[javatest.batch] 07-08-2019 09:21:40:  TRACE: [WIRE] - << "HTTP/1.1 200 OK[\r][\n]"
[javatest.batch] 07-08-2019 09:21:40:  TRACE: [WIRE] - << "X-Powered-By: Servlet/4.0[\r][\n]"
[javatest.batch] 07-08-2019 09:21:40:  TRACE: [WIRE] - << "Content-Type: text/plain;charset=ISO-8859-1[\r][\n]"
[javatest.batch] 07-08-2019 09:21:40:  TRACE: [WIRE] - << "testDate: 2019-07-08 13:21[\r][\n]"
[javatest.batch] 07-08-2019 09:21:40:  TRACE: [WIRE] - << "Content-Language: en-US[\r][\n]"
[javatest.batch] 07-08-2019 09:21:40:  TRACE: [WIRE] - << "Set-Cookie: name1=value1; Expires=Mon, 08-Jul-19 13:21:42 GMT[\r][\n]"
[javatest.batch] 07-08-2019 09:21:40:  TRACE: [WIRE] - << "Transfer-Encoding: chunked[\r][\n]"
[javatest.batch] 07-08-2019 09:21:40:  TRACE: [WIRE] - << "Date: Mon, 08 Jul 2019 13:21:40 GMT[\r][\n]"
[javatest.batch] 07-08-2019 09:21:40:  TRACE: [WIRE] - << "Expires: Thu, 01 Dec 1994 16:00:00 GMT[\r][\n]"
[javatest.batch] 07-08-2019 09:21:40:  TRACE: [WIRE] - << "Cache-Control: no-cache="set-cookie, set-cookie2"[\r][\n]"
[javatest.batch] 07-08-2019 09:21:40:  TRACE: [WIRE] - << "[\r][\n]"
[javatest.batch] 07-08-2019 09:21:40:  TRACE: Found 1 set-cookie entry
[javatest.batch] 07-08-2019 09:21:40:  TRACE: Checking set-cookiei 0:Set-Cookie: name1=value1; Expires=Mon, 08-Jul-19 13:21:42 GMT
[javatest.batch]
[javatest.batch] 07-08-2019 09:21:40:  TRACE: [WIRE] - << "c"
[javatest.batch] 07-08-2019 09:21:40:  TRACE: [WIRE] - << "[\r]"
[javatest.batch] 07-08-2019 09:21:40:  TRACE: [WIRE] - << "[\n]"
[javatest.batch] 07-08-2019 09:21:40:  TRACE: [WIRE] - << "Test PASSED[\n]"
[javatest.batch] 07-08-2019 09:21:40:  TRACE: [WIRE] - << "[\r]"
[javatest.batch] 07-08-2019 09:21:40:  TRACE: [WIRE] - << "[\n]"
[javatest.batch] 07-08-2019 09:21:40:  TRACE: [WIRE] - << "0"
[javatest.batch] 07-08-2019 09:21:40:  TRACE: [WIRE] - << "[\r]"
[javatest.batch] 07-08-2019 09:21:40:  TRACE: [WIRE] - << "[\n]"
[javatest.batch] 07-08-2019 09:21:40:  TRACE: [WIRE] - << "[\r]"
[javatest.batch] 07-08-2019 09:21:40:  TRACE: [WIRE] - << "[\n]"
[javatest.batch] 07-08-2019 09:21:40:  TRACE: [WIRE] - << "[\r][\n]"
[javatest.batch] 07-08-2019 09:21:40:  TRACE: [WIRE] - HttpConnectionManager is null.  Connection cannot be released.
[javatest.batch] 07-08-2019 09:21:40:  ERROR: The expiry date was incorrect, expected =Mon Jul 08 09:21:00 EDT 2019, result = Sat Jul 08 08:21:00 EST 19
[javatest.batch] 07-08-2019 09:21:40:  ERROR: Exception occurred: com.sun.ts.lib.harness.EETest$Fault: The expiry date was incorrect, expected =Mon Jul 08 09:21:00 EDT 2019, result = Sat Jul 08 08:21:00 EST 19
[javatest.batch] 07-08-2019 09:21:40:  ERROR: Test case throws exception: Exception occurred: com.sun.ts.lib.harness.EETest$Fault: The expiry date was incorrect, expected =Mon Jul 08 09:21:00 EDT 2019, result = Sat Jul 08 08:21:00 EST 19
[javatest.batch] 07-08-2019 09:21:40:  ERROR: Exception at:
[javatest.batch] 07-08-2019 09:21:40:  ERROR: com.sun.ts.lib.harness.EETest$Fault: Exception occurred: com.sun.ts.lib.harness.EETest$Fault: The expiry date was incorrect, expected =Mon Jul 08 09:21:00 EDT 2019, result = Sat Jul 08 08:21:00 EST 19
[javatest.batch] at com.sun.ts.tests.servlet.api.javax_servlet_http.cookie.URLClient.setMaxAgePositiveTest(URLClient.java:368)
```

The test used to pass under EE8 and is failing with the Jakarta TCK; it looks like this may be due to changes introduced with 5d63739:
https://github.com/eclipse-ee4j/jakartaee-tck/commit/5d63739aa87016a4bb35516039ac7e83b30298a9#diff-fe27b4530bdef6baa5447c990d9f786f

I rebuilt the test after removing the date format `CUSTOM_HEADER_DATE_FORMAT` and the test passes again. I then tried changing the date format for testDate to match the Netscape format for expiry date of Set-Cookie and it also passes.

```
diff --git a/src/com/sun/ts/tests/servlet/api/javax_servlet_http/cookie/TestServlet.java b/src/com/sun/ts/tests/servlet/api/javax_servlet_http/cookie/TestServlet.java
index db94afa1..4fa54f5f 100644
--- a/src/com/sun/ts/tests/servlet/api/javax_servlet_http/cookie/TestServlet.java
+++ b/src/com/sun/ts/tests/servlet/api/javax_servlet_http/cookie/TestServlet.java
@@ -72,7 +72,7 @@ import java.util.TimeZone;

 public class TestServlet extends HttpTCKServlet {

-  public static String CUSTOM_HEADER_DATE_FORMAT = "yyyy-MM-dd HH:mm";
+  public static String CUSTOM_HEADER_DATE_FORMAT = "E, dd-MM-yy HH:mm:ss";

   public void cloneTest(HttpServletRequest request,
       HttpServletResponse response) throws ServletException, IOException {
```

Note: Our server, by default, uses the latest RFC-compliant date format, but HttpClient did not like it so we had to configure it to use the Netscape cookie expiry format.
```
[javatest.batch] 07-08-2019 10:14:43:  TRACE: [WIRE] - << "testDate: Mon, 07-08-19 14:14:43[\r][\n]"
[javatest.batch] 07-08-2019 10:14:43:  TRACE: [WIRE] - << "Set-Cookie: name1=value1; Expires=Mon, 08 Jul 2019 14:14:45 GMT[\r][\n]"
...
[javatest.batch] 07-08-2019 10:14:43:  ERROR: com.sun.ts.lib.harness.EETest$Fault: Exception occurred:org.apache.commons.httpclient.cookie.MalformedCookieException: Invalid expires attribute: Unparseable date: "Mon, 08 Jul 2019 14:14:45 GMT"
[javatest.batch] at com.sun.ts.tests.servlet.api.javax_servlet_http.cookie.URLClient.setMaxAgePositiveTest(URLClient.java:352)
```

Does this look to be a test issue? Any thoughts on the matter would be appreciated. Thanks!

Regards,
Hank Ibell

Back to the top