1

At some point of time, the network thread keeps failing on retreiving the google.com expires date value (from autoDetectAPN) which fills up the logs. I checked the value in the cookie, it looks like this "fri, 05-jul-2019 07:31:41 gmt" and indeed, this value does not get parsed. I made a quick test (see below). You shall see none of the formats tried by com.codename1.io.ConnectionRequest:parseCookieHeader(String) succeeds. Any idea?

        String date = "fri, 05-jul-2019 07:31:41 gmt";

        String[] formats = new String[] {
        "EEE, dd-MMM-yyyy HH:mm:ss z",
        "EEE dd-MMM-yyyy HH:mm:ss z",
        "EEE, dd MMM yyyy HH:mm:ss z",
        "EEE dd MMM yyyy HH:mm:ss z",
        "EEE, dd-MMM-yyyy HH:mm:ss Z", 
        "EEE dd-MMM-yyyy HH:mm:ss Z",
        "EEE, dd MMM yyyy HH:mm:ss Z",
        "EEE dd MMM yyyy HH:mm:ss Z",
        "EEE, dd-MMM-yy HH:mm:ss z", 
        "EEE dd-MMM-yy HH:mm:ss z",
        "EEE, dd MMM yy HH:mm:ss z",
        "EEE dd MMM yy HH:mm:ss z",
        "EEE, dd-MMM-yy HH:mm:ss Z", 
        "EEE dd-MMM-yy HH:mm:ss Z",
        "EEE, dd MMM yy HH:mm:ss Z",
        "EEE dd MMM yy HH:mm:ss Z"
        };

        for (String format : formats) {
            try {
                com.codename1.l10n.SimpleDateFormat sdf = new com.codename1.l10n.SimpleDateFormat(format);
                System.out.println(date + " format: " + format + " => " + sdf.parse(date).getTime());
            } catch (Throwable t){
                System.out.println(date + " format: " + format + " => Nope");
            }
        }
``
And the result is:
    fri, 05-jul-2019 07:31:41 gmt format: EEE, dd-MMM-yyyy HH:mm:ss z => Nope
    fri, 05-jul-2019 07:31:41 gmt format: EEE dd-MMM-yyyy HH:mm:ss z => Nope
    fri, 05-jul-2019 07:31:41 gmt format: EEE, dd MMM yyyy HH:mm:ss z => Nope
    fri, 05-jul-2019 07:31:41 gmt format: EEE dd MMM yyyy HH:mm:ss z => Nope
    fri, 05-jul-2019 07:31:41 gmt format: EEE, dd-MMM-yyyy HH:mm:ss Z => Nope
    fri, 05-jul-2019 07:31:41 gmt format: EEE dd-MMM-yyyy HH:mm:ss Z => Nope
    fri, 05-jul-2019 07:31:41 gmt format: EEE, dd MMM yyyy HH:mm:ss Z => Nope
    fri, 05-jul-2019 07:31:41 gmt format: EEE dd MMM yyyy HH:mm:ss Z => Nope
    fri, 05-jul-2019 07:31:41 gmt format: EEE, dd-MMM-yy HH:mm:ss z => Nope
    fri, 05-jul-2019 07:31:41 gmt format: EEE dd-MMM-yy HH:mm:ss z => Nope
    fri, 05-jul-2019 07:31:41 gmt format: EEE, dd MMM yy HH:mm:ss z => Nope
    fri, 05-jul-2019 07:31:41 gmt format: EEE dd MMM yy HH:mm:ss z => Nope
    fri, 05-jul-2019 07:31:41 gmt format: EEE, dd-MMM-yy HH:mm:ss Z => Nope
    fri, 05-jul-2019 07:31:41 gmt format: EEE dd-MMM-yy HH:mm:ss Z => Nope
    fri, 05-jul-2019 07:31:41 gmt format: EEE, dd MMM yy HH:mm:ss Z => Nope
    fri, 05-jul-2019 07:31:41 gmt format: EEE dd MMM yy HH:mm:ss Z => Nope
Ole V.V.
  • 81,772
  • 15
  • 137
  • 161
ebardet
  • 230
  • 1
  • 9
  • Possible duplicate of [Java - Unparseable date](https://stackoverflow.com/questions/6154772/java-unparseable-date). And of [Date format parse exception - “EEE MMM dd HH:mm:ss Z yyyy” [duplicate\]](https://stackoverflow.com/questions/19861642/date-format-parse-exception-eee-mmm-dd-hhmmss-z-yyyy). – Ole V.V. Jun 29 '19 at 09:42
  • I just ran this on my machine and got this for the first entry: `fri, 05-jul-2019 07:31:41 gmt format: EEE, dd-MMM-yyyy HH:mm:ss z => 1562311901000` Are you using the current version of the libraries? – Shai Almog Jun 06 '19 at 02:35
  • Hello Shai, thanks for answering. I assume I am running the current version : – ebardet Jun 06 '19 at 06:45
  • Hello @shai-almog, thanks for answering. I assume I am running the current version, on Eclipse: - CodenameOne http://www.codenameone.com/files/eclipse/site.xml Enabled - Refreshed the libs on my project - CodenameOne.jar is 6,127,060 bytes last modified on June 3, 2019 at 4:32:15 PM - Version #e72cf75cb5c21f23295f0d5ae3be4fc3d45ba5f1 Let me know if something's wrong. – ebardet Jun 06 '19 at 06:51
  • Open Codename One Settings. Go to Basic -> Update Project Libs – Shai Almog Jun 07 '19 at 04:38
  • Yes. I did that many times (actually on Eclipse so did: Project->CodenameOne->Refresh Libs) but I still get this pardsing error. – ebardet Jun 11 '19 at 12:25
  • Sorry. The cn1 jar Version is now b13e87ec4b137751fec556c1bf8c1d93ee77c074. I shall see if this works better... I'll let you know. – ebardet Jun 11 '19 at 12:32
  • Nope ;( still the same message: [Network Thread] 0:0:36,38 - Failed to parse expires date thu, 11-jul-2019 12:34:54 gmt for cookie – ebardet Jun 11 '19 at 12:35
  • No. It's in Codename One Settings. If this doesn't work for your your Eclipse plugin might be out of date too, it should be 6.2. Refresh Libs is something completely different... – Shai Almog Jun 12 '19 at 03:31
  • Hello Shai, I did. I even re-installed the plugin. Still no luck. Any other idea? Thanks for your help. – ebardet Jun 20 '19 at 07:55
  • What's the library version in version.properties? Do you store the project jars in version control (you shouldn't) – Shai Almog Jun 21 '19 at 03:32
  • Hello Shai, the version.properties containes : # #Wed Jun 26 13:59:01 CEST 2019 CodenameOne_SRCzip=76 CodenameOneJar=76 CodeNameOneBuildClientJar=17 CLDC11Jar=18 JavaSEJar=76 And my .gitignore contains the string *.jar I'm really left with no clue here :( – ebardet Jun 26 '19 at 12:31
  • I have no idea. This is the current version and should work exactly as my version should, to make sure I stepped in with the debugger and saw that the correct code pathways were hit when processing this which means this logic is handled correctly in our code. – Shai Almog Jun 27 '19 at 03:06
  • Hello Shai, I guess I found the culprit. I'll add an answer to that question to get more room for explanation. – ebardet Jun 27 '19 at 16:35
  • This has nothing to do with those questions as this is in Codename One and this SimpleDateFormat is in the com.codename1.i18n package which is a different thing entirely. Notice his answer is correct and it has nothing to do with the answers to these other questions – Shai Almog Jul 01 '19 at 03:27

0 Answers0