You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@commons.apache.org by "Aaron Sheldon (JIRA)" <ji...@apache.org> on 2015/04/18 23:09:58 UTC
[jira] [Comment Edited] (LANG-1116) testLang530 fails for some
timezones
[ https://issues.apache.org/jira/browse/LANG-1116?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14501586#comment-14501586 ]
Aaron Sheldon edited comment on LANG-1116 at 4/18/15 9:09 PM:
--------------------------------------------------------------
I modified the test locally to run 100,000 times and unfortunately I cannot reproduce this failure. The unix time of these appears to differ by four seconds in your run.
1429382379.517
1429382383.517
{code:java}
// http://issues.apache.org/jira/browse/LANG-530
@Test
public void testLang530() throws ParseException {
for (int i = 0 ; i < 100000; i++) {
for (final String timezoneId : TimeZone.getAvailableIDs()) {
final TimeZone timezone = TimeZone.getTimeZone(timezoneId);
final Calendar calendar = new GregorianCalendar(timezone);
final String isoDateStr = DateFormatUtils.ISO_DATETIME_TIME_ZONE_FORMAT.format(calendar);
final Date d2 = DateUtils.parseDate(isoDateStr, new String[] { DateFormatUtils.ISO_DATETIME_TIME_ZONE_FORMAT.getPattern() });
// the format loses milliseconds so have to reintroduce them
assertEquals("Date not equal to itself ISO formatted and parsed", calendar.getTimeInMillis(), d2.getTime() + calendar.getTimeInMillis() % 1000);
}
}
}
{code}
I artificially added 1 second sleeps in my test code between each step but I still don't have test failures. It might be worth noting that I tested this patch against the 3.4 release rather than trunk.
was (Author: asheldon):
I modified the test locally to run 100,000 times and unfortunately I cannot reproduce this failure. The unix time of these appears to differ by four seconds in your run.
1429382379.517
1429382383.517
// http://issues.apache.org/jira/browse/LANG-530
@Test
public void testLang530() throws ParseException {
for (int i = 0 ; i < 100000; i++) {
for (final String timezoneId : TimeZone.getAvailableIDs()) {
final TimeZone timezone = TimeZone.getTimeZone(timezoneId);
final Calendar calendar = new GregorianCalendar(timezone);
final String isoDateStr = DateFormatUtils.ISO_DATETIME_TIME_ZONE_FORMAT.format(calendar);
final Date d2 = DateUtils.parseDate(isoDateStr, new String[] { DateFormatUtils.ISO_DATETIME_TIME_ZONE_FORMAT.getPattern() });
// the format loses milliseconds so have to reintroduce them
assertEquals("Date not equal to itself ISO formatted and parsed", calendar.getTimeInMillis(), d2.getTime() + calendar.getTimeInMillis() % 1000);
}
}
}
I artificially added 1 second sleeps in my test code between each step but I still don't have test failures. It might be worth noting that I tested this patch against the 3.4 release rather than trunk.
> testLang530 fails for some timezones
> ------------------------------------
>
> Key: LANG-1116
> URL: https://issues.apache.org/jira/browse/LANG-1116
> Project: Commons Lang
> Issue Type: Bug
> Components: lang.time.*
> Affects Versions: 3.4
> Environment: Redhat 5 / Java8u45
> Reporter: Aaron Sheldon
> Fix For: Review Patch
>
> Attachments: lang-1116.patch
>
>
> Unit test for testLang530 fails when the isoDateStr comes out with just a Z instead of +00:00.
> Tests run: 38, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 0.014 sec <<< FAILURE! - in org.apache.commons.lang3.time.DateUtilsTest
> testLang530(org.apache.commons.lang3.time.DateUtilsTest) Time elapsed: 0.005 sec <<< ERROR!
> java.text.ParseException: Unable to parse the date: 2015-04-17T18:51:52Z
> at org.apache.commons.lang3.time.DateUtils.parseDateWithLeniency(DateUtils.java:401)
> at org.apache.commons.lang3.time.DateUtils.parseDate(DateUtils.java:301)
> at org.apache.commons.lang3.time.DateUtils.parseDate(DateUtils.java:278)
> at org.apache.commons.lang3.time.DateUtilsTest.testLang530(DateUtilsTest.java:1222)
> On a Linux machine where this test passes, isoDateStr is 2015-04-17T19:26:03+00:00.
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)