GeoTools
  1. GeoTools
  2. GEOT-1299

MemoryDataStore lock tests fail at random.

    Details

    • Type: Bug Bug
    • Status: Closed Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 2.4-M3
    • Fix Version/s: 2.4-M4
    • Component/s: main
    • Labels:
      None

      Description

      This one is silly .. but an interesting lesson in cpu design changes.

      public void testGetFeatureLockingExpire() throws Exception {
              FeatureLock lock = FeatureLockFactory.generate("Timed", 1);
              FeatureLocking road = (FeatureLocking) data.getFeatureSource("road");
              road.setFeatureLock(lock);
              assertFalse(isLocked("road", "road.rd1"));
              road.lockFeatures(rd1Filter);
              assertTrue(isLocked("road", "road.rd1"));
              Thread.sleep(50);
              assertFalse(isLocked("road", "road.rd1"));
          }
      

      Andrea says:
      There is no concurrency whatsoever here. The only thing
      that may make it failing is the duration of the sleep itself,
      which seems to be very small. On my computer for example I apparently cannot measure time differences of time less than 15ms.

      In fact, if I change the sleep time to be less than 15ms,
      the test starts to randomly fail, and consistenly fails if I use
      less than 5ms. Mine is a windows xp box.

        Activity

        Hide
        Jody Garnett added a comment -
        So the trick must be to wait until a measurable time has past - as measured by System.currentTimeMillis()

        {code}
        long then = System.currentTimeMillis();
        do {
            Thread.sleep( 15 );
        } while ( then == System.currentTimeMillis() );
        {code}

        Trying this out.
        Show
        Jody Garnett added a comment - So the trick must be to wait until a measurable time has past - as measured by System.currentTimeMillis() {code} long then = System.currentTimeMillis(); do {     Thread.sleep( 15 ); } while ( then == System.currentTimeMillis() ); {code} Trying this out.
        Hide
        Jody Garnett added a comment -
        We should push this fix out to other lock tests.
        Show
        Jody Garnett added a comment - We should push this fix out to other lock tests.
        Hide
        Jody Garnett added a comment -
        Applied the fix in a few other spots:
        - mySQLDataStoreAPITest
        - PostgisDataStoreAPIOnlineTest
        Show
        Jody Garnett added a comment - Applied the fix in a few other spots: - mySQLDataStoreAPITest - PostgisDataStoreAPIOnlineTest

          People

          • Assignee:
            James Macgill
            Reporter:
            Jody Garnett
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: