[ https://issues.apache.org/jira/browse/LUCENE-2155?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Robert Muir updated LUCENE-2155: -------------------------------- Attachment: LUCENE-2155.patch attached is a patch that not only clears all Calendar attributes to erase anything dependent on local time, but also ensures the same hour/minute/second/millisecond is used for actual and expected. This is because the date in the test (2002/1/4) becomes two different Thai dates, depending upon the hour of day, timezone, etc. The expected end date was always 4/2/2545, because these were set. But the actual end date would sometimes be 3/2/2545, depending upon when and where you ran the tests. > random localization test failures > --------------------------------- > > Key: LUCENE-2155 > URL: https://issues.apache.org/jira/browse/LUCENE-2155 > Project: Lucene - Java > Issue Type: Task > Reporter: Robert Muir > Assignee: Robert Muir > Priority: Minor > Fix For: 3.1 > > Attachments: LUCENE-2155.patch > > > Some tests fail randomly (hard to reproduce). It appears to me that this is > caused by uninitialized date fields. For example Uwe reported a failure today > in this test of TestQueryParser: > {code} > /** for testing legacy DateField support */ > public void testLegacyDateRange() throws Exception { > String startDate = getLocalizedDate(2002, 1, 1, false); > String endDate = getLocalizedDate(2002, 1, 4, false); > {code} > if you look at the helper getLocalizedDate, you can see if the 4th argument > is false, it does not initialize all date field functions. > {code} > private String getLocalizedDate(int year, int month, int day, boolean > extendLastDate) { > Calendar calendar = new GregorianCalendar(); > calendar.set(year, month, day); > if (extendLastDate) { > calendar.set(Calendar.HOUR_OF_DAY, 23); > calendar.set(Calendar.MINUTE, 59); > calendar.set(Calendar.SECOND, 59); > ... > } > {code} > I think the solution to this is that in all tests, whereever we create new > GregorianCalendar(), it should be followed by a call to Calendar.clear(). > This will ensure that we always initialize unused calendar fields to zero, > rather than being dependent on the local time. -- This message is automatically generated by JIRA. - You can reply to this email to add a comment to the issue online. --------------------------------------------------------------------- To unsubscribe, e-mail: java-dev-unsubscr...@lucene.apache.org For additional commands, e-mail: java-dev-h...@lucene.apache.org