Uploaded image for project: 'Commons Configuration'
  1. Commons Configuration
  2. CONFIGURATION-302

FileChangedReloadingStrategy.reloadingRequired() can fail

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: 1.5
    • Fix Version/s: 1.6
    • Component/s: None
    • Labels:
      None

      Description

      If reloadingRequired() returns true and you call it again before calling reloadingPerformed(), the 2nd time it can return false (but you have not yet reloaded!) because it doesn't check the file system again until the refresh delay is expired.
      Of course this is a very unusual test case (usually you reload immediately) but the behaviour of the method should be consistent in this case too: if reloadingRequired() returns true any subsequent call to this method should return true until reloadingPerformed() is called.

      In my project I have fixed the method by promoting the flag called "reloading" to class scope so I that can check whether the previous call returned true or false:

      protected boolean reloading = false;
      public boolean reloadingRequired()
      {
      if (!reloading)
      {
      long now = System.currentTimeMillis();
      if (now > lastChecked + refreshDelay)
      {
      lastChecked = now;
      if (hasChanged())

      { reloading = true; }

      }
      }
      return reloading;
      }

      Of course I reset this flag in init() and reloadingPerformed().

        Attachments

          Activity

            People

            • Assignee:
              oheger Oliver Heger
              Reporter:
              pnavato Pino Navato
            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: