[jira] [Commented] (NET-710) Timestamp parsing fails around the change to daylight savings

2024-05-07 Thread Jacob Vandborg (Jira)


[ 
https://issues.apache.org/jira/browse/NET-710?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17844377#comment-17844377
 ] 

Jacob Vandborg commented on NET-710:


I've tested a bit more and now see where I've made a mistake. While setting up 
the FTP client I'm not specifically setting the TZ of the server I'm connecting 
to. Because of this the LIST entries are parsed using the TZ of the machine 
running the FTP client and currently my machine is setup with TZ CET.

The following code will result in ParseException
{code:java}
public static void main(String[] args) throws ParseException {

FTPClientConfig ftpClientConfig = new FTPClientConfig();
ftpClientConfig.setServerTimeZoneId("CET"); // Wrong TZ for server just to 
demonstrate my mistake
ftpClientConfig.setDefaultDateFormatStr("MMM d ");
ftpClientConfig.setRecentDateFormatStr("MMM d HH:mm");

FTPTimestampParserImpl ftpTimestampParser = new FTPTimestampParserImpl();
ftpTimestampParser.configure(ftpClientConfig);

Calendar c = ftpTimestampParser.parseTimestamp("Mar 31 02:37", 
Calendar.getInstance());

}
{code}

The following code works and does not throw ParseException
{code:java}
public static void main(String[] args) throws ParseException {

FTPClientConfig ftpClientConfig = new FTPClientConfig();
ftpClientConfig.setServerTimeZoneId("UTC"); // Correct TZ for server
ftpClientConfig.setDefaultDateFormatStr("MMM d ");
ftpClientConfig.setRecentDateFormatStr("MMM d HH:mm");

FTPTimestampParserImpl ftpTimestampParser = new FTPTimestampParserImpl();
ftpTimestampParser.configure(ftpClientConfig);

Calendar c = ftpTimestampParser.parseTimestamp("Mar 31 02:37", 
Calendar.getInstance());

}
{code}

Thank you for your support Sebb and sorry for wasting your time.

Best regards,
Jacob

> Timestamp parsing fails around the change to daylight savings
> -
>
> Key: NET-710
> URL: https://issues.apache.org/jira/browse/NET-710
> Project: Commons Net
>  Issue Type: Bug
>  Components: FTP
>Affects Versions: 3.3, 3.8.0
>Reporter: Mike Baranczak
>Priority: Major
>
> {{String ts = "Mar 13 02:33";}}
> {{Calendar serverTime = Calendar.getInstance(TimeZone.getTimeZone("EDT"), 
> Locale.US);}}
> {{serverTime.set(2022, 2, 16, 14, 0);}}
> {{Calendar c = new FTPTimestampParserImpl().parseTimestamp(ts, serverTime);}}
>  
> {{Result:}}
>  
> {{java.text.ParseException: Timestamp 'Mar 13 02:33' could not be parsed 
> using a server time of Wed Mar 16 10:00:54 EDT 2022}}
> {{    at 
> org.apache.commons.net.ftp.parser.FTPTimestampParserImpl.parseTimestamp 
> (FTPTimestampParserImpl.java:246)}}
>  
> I can't tell what's going on, but this seems to have something to do with the 
> transition to Daylight Savings Time, which happened on Sunday, March 13. I 
> ran into this bug when trying to get a list of recent files from an FTP 
> server.  (UnixFTPEntryParser ignores the exception silently, which isn't a 
> great idea, either.)



--
This message was sent by Atlassian Jira
(v8.20.10#820010)


[jira] [Commented] (NET-710) Timestamp parsing fails around the change to daylight savings

2024-05-07 Thread Sebb (Jira)


[ 
https://issues.apache.org/jira/browse/NET-710?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17844357#comment-17844357
 ] 

Sebb commented on NET-710:
--

Remember that the listing is generated in the timezone of the server, so 
timestamps only have to make sense in that context.

I'm inclined to close the issue as invalid, unless it can be shown that parsing 
fails when the appropriate server time parameter is provided.

BTW, modern FTP servers are likely to support MLSD/MLST which do not suffer 
from parsing issues; they should be used rather than LIST where possible.

> Timestamp parsing fails around the change to daylight savings
> -
>
> Key: NET-710
> URL: https://issues.apache.org/jira/browse/NET-710
> Project: Commons Net
>  Issue Type: Bug
>  Components: FTP
>Affects Versions: 3.3, 3.8.0
>Reporter: Mike Baranczak
>Priority: Major
>
> {{String ts = "Mar 13 02:33";}}
> {{Calendar serverTime = Calendar.getInstance(TimeZone.getTimeZone("EDT"), 
> Locale.US);}}
> {{serverTime.set(2022, 2, 16, 14, 0);}}
> {{Calendar c = new FTPTimestampParserImpl().parseTimestamp(ts, serverTime);}}
>  
> {{Result:}}
>  
> {{java.text.ParseException: Timestamp 'Mar 13 02:33' could not be parsed 
> using a server time of Wed Mar 16 10:00:54 EDT 2022}}
> {{    at 
> org.apache.commons.net.ftp.parser.FTPTimestampParserImpl.parseTimestamp 
> (FTPTimestampParserImpl.java:246)}}
>  
> I can't tell what's going on, but this seems to have something to do with the 
> transition to Daylight Savings Time, which happened on Sunday, March 13. I 
> ran into this bug when trying to get a list of recent files from an FTP 
> server.  (UnixFTPEntryParser ignores the exception silently, which isn't a 
> great idea, either.)



--
This message was sent by Atlassian Jira
(v8.20.10#820010)


[jira] [Commented] (NET-710) Timestamp parsing fails around the change to daylight savings

2024-05-07 Thread Sebb (Jira)


[ 
https://issues.apache.org/jira/browse/NET-710?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17844338#comment-17844338
 ] 

Sebb commented on NET-710:
--

I still cannot reproduce the issue.
What TZ are you running the test under?

Note that the serverTime parameter is supposed to represent the server time, so 
should use the server TZ and timestamp.

> Timestamp parsing fails around the change to daylight savings
> -
>
> Key: NET-710
> URL: https://issues.apache.org/jira/browse/NET-710
> Project: Commons Net
>  Issue Type: Bug
>  Components: FTP
>Affects Versions: 3.3, 3.8.0
>Reporter: Mike Baranczak
>Priority: Major
>
> {{String ts = "Mar 13 02:33";}}
> {{Calendar serverTime = Calendar.getInstance(TimeZone.getTimeZone("EDT"), 
> Locale.US);}}
> {{serverTime.set(2022, 2, 16, 14, 0);}}
> {{Calendar c = new FTPTimestampParserImpl().parseTimestamp(ts, serverTime);}}
>  
> {{Result:}}
>  
> {{java.text.ParseException: Timestamp 'Mar 13 02:33' could not be parsed 
> using a server time of Wed Mar 16 10:00:54 EDT 2022}}
> {{    at 
> org.apache.commons.net.ftp.parser.FTPTimestampParserImpl.parseTimestamp 
> (FTPTimestampParserImpl.java:246)}}
>  
> I can't tell what's going on, but this seems to have something to do with the 
> transition to Daylight Savings Time, which happened on Sunday, March 13. I 
> ran into this bug when trying to get a list of recent files from an FTP 
> server.  (UnixFTPEntryParser ignores the exception silently, which isn't a 
> great idea, either.)



--
This message was sent by Atlassian Jira
(v8.20.10#820010)


[jira] [Commented] (NET-710) Timestamp parsing fails around the change to daylight savings

2024-05-07 Thread Jacob Vandborg (Jira)


[ 
https://issues.apache.org/jira/browse/NET-710?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17844276#comment-17844276
 ] 

Jacob Vandborg commented on NET-710:


Hi [~sebb],

Thank you for looking into this issue.

I've also not been able to replicate the mentioned error using sample code 
provided, but I've successfully been able to replicate the problem using this 
example:

{code:java}
public static void main(String[] args) throws ParseException {
String ts = "Mar 31 02:37";
Calendar serverTime = Calendar.getInstance(TimeZone.getTimeZone("CET"), 
Locale.forLanguageTag("da"));
Calendar c = new FTPTimestampParserImpl().parseTimestamp(ts, serverTime);
}
{code}

When debugging through FTPTimestampParserImpl it seems the problems start 
around line 159 
{noformat}
parsed = hackFormatter.parse(timeStampStrPlusYear, pp);
{noformat}
where the method call returns null into 'parsed'-variable 

I've tested above in commons-net 3.10 on the following java version:
{noformat}
openjdk 17.0.11 2024-04-16
OpenJDK Runtime Environment Temurin-17.0.11+9 (build 17.0.11+9)
OpenJDK 64-Bit Server VM Temurin-17.0.11+9 (build 17.0.11+9, mixed mode)
{noformat}

The SFTP server I've connected to is running UTC and therefore does not 
observer daylight saving time.

Best regards,
Jacob

> Timestamp parsing fails around the change to daylight savings
> -
>
> Key: NET-710
> URL: https://issues.apache.org/jira/browse/NET-710
> Project: Commons Net
>  Issue Type: Bug
>  Components: FTP
>Affects Versions: 3.3, 3.8.0
>Reporter: Mike Baranczak
>Priority: Major
>
> {{String ts = "Mar 13 02:33";}}
> {{Calendar serverTime = Calendar.getInstance(TimeZone.getTimeZone("EDT"), 
> Locale.US);}}
> {{serverTime.set(2022, 2, 16, 14, 0);}}
> {{Calendar c = new FTPTimestampParserImpl().parseTimestamp(ts, serverTime);}}
>  
> {{Result:}}
>  
> {{java.text.ParseException: Timestamp 'Mar 13 02:33' could not be parsed 
> using a server time of Wed Mar 16 10:00:54 EDT 2022}}
> {{    at 
> org.apache.commons.net.ftp.parser.FTPTimestampParserImpl.parseTimestamp 
> (FTPTimestampParserImpl.java:246)}}
>  
> I can't tell what's going on, but this seems to have something to do with the 
> transition to Daylight Savings Time, which happened on Sunday, March 13. I 
> ran into this bug when trying to get a list of recent files from an FTP 
> server.  (UnixFTPEntryParser ignores the exception silently, which isn't a 
> great idea, either.)



--
This message was sent by Atlassian Jira
(v8.20.10#820010)


[jira] [Commented] (NET-710) Timestamp parsing fails around the change to daylight savings

2024-05-07 Thread Sebb (Jira)


[ 
https://issues.apache.org/jira/browse/NET-710?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17844233#comment-17844233
 ] 

Sebb commented on NET-710:
--

I've added a separate branch which tests against the release jars from 3.7 
through to 3.10.0 using windows, ubuntu and macOS.

All succeed.

https://github.com/apache/commons-net/actions/runs/8983633260

We cannot fix something that does not break for us.

> Timestamp parsing fails around the change to daylight savings
> -
>
> Key: NET-710
> URL: https://issues.apache.org/jira/browse/NET-710
> Project: Commons Net
>  Issue Type: Bug
>  Components: FTP
>Affects Versions: 3.3, 3.8.0
>Reporter: Mike Baranczak
>Priority: Major
>
> {{String ts = "Mar 13 02:33";}}
> {{Calendar serverTime = Calendar.getInstance(TimeZone.getTimeZone("EDT"), 
> Locale.US);}}
> {{serverTime.set(2022, 2, 16, 14, 0);}}
> {{Calendar c = new FTPTimestampParserImpl().parseTimestamp(ts, serverTime);}}
>  
> {{Result:}}
>  
> {{java.text.ParseException: Timestamp 'Mar 13 02:33' could not be parsed 
> using a server time of Wed Mar 16 10:00:54 EDT 2022}}
> {{    at 
> org.apache.commons.net.ftp.parser.FTPTimestampParserImpl.parseTimestamp 
> (FTPTimestampParserImpl.java:246)}}
>  
> I can't tell what's going on, but this seems to have something to do with the 
> transition to Daylight Savings Time, which happened on Sunday, March 13. I 
> ran into this bug when trying to get a list of recent files from an FTP 
> server.  (UnixFTPEntryParser ignores the exception silently, which isn't a 
> great idea, either.)



--
This message was sent by Atlassian Jira
(v8.20.10#820010)


[jira] [Commented] (NET-710) Timestamp parsing fails around the change to daylight savings

2024-05-06 Thread Sebb (Jira)


[ 
https://issues.apache.org/jira/browse/NET-710?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17844070#comment-17844070
 ] 

Sebb commented on NET-710:
--

Cannot reproduce the error on 3.10.0 or 3.9.0 using Java8 and Ubuntu.
See the GHA log here
https://github.com/apache/commons-net/actions/runs/8977664771

We will need more details on OS and Java versions

> Timestamp parsing fails around the change to daylight savings
> -
>
> Key: NET-710
> URL: https://issues.apache.org/jira/browse/NET-710
> Project: Commons Net
>  Issue Type: Bug
>  Components: FTP
>Affects Versions: 3.3, 3.8.0
>Reporter: Mike Baranczak
>Priority: Major
>
> {{String ts = "Mar 13 02:33";}}
> {{Calendar serverTime = Calendar.getInstance(TimeZone.getTimeZone("EDT"), 
> Locale.US);}}
> {{serverTime.set(2022, 2, 16, 14, 0);}}
> {{Calendar c = new FTPTimestampParserImpl().parseTimestamp(ts, serverTime);}}
>  
> {{Result:}}
>  
> {{java.text.ParseException: Timestamp 'Mar 13 02:33' could not be parsed 
> using a server time of Wed Mar 16 10:00:54 EDT 2022}}
> {{    at 
> org.apache.commons.net.ftp.parser.FTPTimestampParserImpl.parseTimestamp 
> (FTPTimestampParserImpl.java:246)}}
>  
> I can't tell what's going on, but this seems to have something to do with the 
> transition to Daylight Savings Time, which happened on Sunday, March 13. I 
> ran into this bug when trying to get a list of recent files from an FTP 
> server.  (UnixFTPEntryParser ignores the exception silently, which isn't a 
> great idea, either.)



--
This message was sent by Atlassian Jira
(v8.20.10#820010)


[jira] [Commented] (NET-710) Timestamp parsing fails around the change to daylight savings

2024-05-04 Thread Gary D. Gregory (Jira)


[ 
https://issues.apache.org/jira/browse/NET-710?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17843488#comment-17843488
 ] 

Gary D. Gregory commented on NET-710:
-

Do you have a unit test we can debug?

> Timestamp parsing fails around the change to daylight savings
> -
>
> Key: NET-710
> URL: https://issues.apache.org/jira/browse/NET-710
> Project: Commons Net
>  Issue Type: Bug
>  Components: FTP
>Affects Versions: 3.3, 3.8.0
>Reporter: Mike Baranczak
>Priority: Major
>
> {{String ts = "Mar 13 02:33";}}
> {{Calendar serverTime = Calendar.getInstance(TimeZone.getTimeZone("EDT"), 
> Locale.US);}}
> {{serverTime.set(2022, 2, 16, 14, 0);}}
> {{Calendar c = new FTPTimestampParserImpl().parseTimestamp(ts, serverTime);}}
>  
> {{Result:}}
>  
> {{java.text.ParseException: Timestamp 'Mar 13 02:33' could not be parsed 
> using a server time of Wed Mar 16 10:00:54 EDT 2022}}
> {{    at 
> org.apache.commons.net.ftp.parser.FTPTimestampParserImpl.parseTimestamp 
> (FTPTimestampParserImpl.java:246)}}
>  
> I can't tell what's going on, but this seems to have something to do with the 
> transition to Daylight Savings Time, which happened on Sunday, March 13. I 
> ran into this bug when trying to get a list of recent files from an FTP 
> server.  (UnixFTPEntryParser ignores the exception silently, which isn't a 
> great idea, either.)



--
This message was sent by Atlassian Jira
(v8.20.10#820010)


[jira] [Commented] (NET-710) Timestamp parsing fails around the change to daylight savings

2024-04-18 Thread Jacob Vandborg (Jira)


[ 
https://issues.apache.org/jira/browse/NET-710?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17838535#comment-17838535
 ] 

Jacob Vandborg commented on NET-710:


There is still a problem with DST in FTPTimestampParserImpl. Latest encounter 
for myself was on Mar 31 04:37 CET using commons-net:commons-net:3.10.0

> Timestamp parsing fails around the change to daylight savings
> -
>
> Key: NET-710
> URL: https://issues.apache.org/jira/browse/NET-710
> Project: Commons Net
>  Issue Type: Bug
>  Components: FTP
>Affects Versions: 3.3, 3.8.0
>Reporter: Mike Baranczak
>Priority: Major
>
> {{String ts = "Mar 13 02:33";}}
> {{Calendar serverTime = Calendar.getInstance(TimeZone.getTimeZone("EDT"), 
> Locale.US);}}
> {{serverTime.set(2022, 2, 16, 14, 0);}}
> {{Calendar c = new FTPTimestampParserImpl().parseTimestamp(ts, serverTime);}}
>  
> {{Result:}}
>  
> {{java.text.ParseException: Timestamp 'Mar 13 02:33' could not be parsed 
> using a server time of Wed Mar 16 10:00:54 EDT 2022}}
> {{    at 
> org.apache.commons.net.ftp.parser.FTPTimestampParserImpl.parseTimestamp 
> (FTPTimestampParserImpl.java:246)}}
>  
> I can't tell what's going on, but this seems to have something to do with the 
> transition to Daylight Savings Time, which happened on Sunday, March 13. I 
> ran into this bug when trying to get a list of recent files from an FTP 
> server.  (UnixFTPEntryParser ignores the exception silently, which isn't a 
> great idea, either.)



--
This message was sent by Atlassian Jira
(v8.20.10#820010)