Uploaded image for project: 'Lucene - Core'
  1. Lucene - Core
  2. LUCENE-2155

random localization test failures

Details

    • Task
    • Status: Closed
    • Minor
    • Resolution: Fixed
    • None
    • 4.0-ALPHA
    • None
    • None
    • New

    Description

      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:

       /** for testing legacy DateField support */
        public void testLegacyDateRange() throws Exception {
          String startDate = getLocalizedDate(2002, 1, 1, false);
          String endDate = getLocalizedDate(2002, 1, 4, false);
      

      if you look at the helper getLocalizedDate, you can see if the 4th argument is false, it does not initialize all date field functions.

        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);
       ...
      }
      

      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.

      Attachments

        1. LUCENE-2155.patch
          11 kB
          Robert Muir

        Activity

          People

            rcmuir Robert Muir
            rcmuir Robert Muir
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: