No error message if updating the index queue flush timestamp fails

XMLWordPrintable

      In com.atlassian.confluence.search.lucene.queue.DatabaseIndexTaskQueue.touchTimestamp() we don't check the return value of timestamp.setLastModified(ts). We should instead throw an exception if the update fails.

      Here is the possible fix as suggested by one of our customers on the forums:

      Change

          private synchronized long touchTimestamp()
          {
              long ts = System.currentTimeMillis();
              try
              {
                  File timestamp = getTimestampFile();
                  if (!timestamp.exists() && !timestamp.getParentFile().mkdirs() && !timestamp.createNewFile())
                  {
                      // error.
                      throw new IOException("Failed to create timestamp file.");
                  }
                  timestamp.setLastModified(ts);
              }
              catch (IOException e)
              {
                  log.error("", e);
              }
      
              return ts;
          }
      

      to

      
      private synchronized long touchTimestamp()
          {
              long ts = System.currentTimeMillis();
              try
              {
                  File timestamp = getTimestampFile();
                  if (!timestamp.exists() && !timestamp.getParentFile().mkdirs() && !timestamp.createNewFile())
                  {
                      // error.
                      throw new IOException("Failed to create timestamp file.");
                  }
                  if (!timestamp.setLastModified(ts))
      		{
      		    // error.
                      throw new IOException("Failed to update timestamp file.");
      		}
              }
              catch (IOException e)
              {
                  log.error("", e);
              }
      
              return ts;
          }
      
      

            Assignee:
            Unassigned
            Reporter:
            Chris Kiehl
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved: