mirror of https://github.com/OpenIdentityPlatform/OpenDJ.git

abobrov
24.44.2007 e3f08f5681f4f08b8827b982efb0e3c42bfc9aba
- fix FindBugs positives.

3 files modified
62 ■■■■■ changed files
opends/src/server/org/opends/server/extensions/FIFOEntryCache.java 20 ●●●● patch | view | raw | blame | history
opends/src/server/org/opends/server/extensions/FileSystemEntryCache.java 33 ●●●●● patch | view | raw | blame | history
opends/src/server/org/opends/server/extensions/SoftReferenceEntryCache.java 9 ●●●●● patch | view | raw | blame | history
opends/src/server/org/opends/server/extensions/FIFOEntryCache.java
@@ -188,24 +188,20 @@
  {
    cacheLock.lock();
    try {
    registeredConfiguration.removeFIFOChangeListener (this);
    // Release all memory currently in use by this cache.
    try
    {
      try {
      idMap.clear();
      dnMap.clear();
    }
    catch (Exception e)
    {
      } catch (Exception e) {
      // This should never happen.
      if (debugEnabled())
      {
        if (debugEnabled()) {
        TRACER.debugCaught(DebugLogLevel.ERROR, e);
      }
    }
    finally
    {
    } finally {
      cacheLock.unlock();
    }
  }
@@ -732,7 +728,11 @@
  /**
   * {@inheritDoc}
   * Clears all entries at or below the specified base DN that are associated
   * with the given backend.  The caller must already hold the cache lock.
   *
   * @param  baseDN   The base DN below which all entries should be flushed.
   * @param  backend  The backend for which to remove the appropriate entries.
   */
  private void clearSubtree(DN baseDN, Backend backend)
  {
opends/src/server/org/opends/server/extensions/FileSystemEntryCache.java
@@ -486,6 +486,7 @@
    cacheWriteLock.lock();
    try {
    registeredConfiguration.removeFileSystemChangeListener (this);
    // Store index/maps in case of persistent cache. Since the cache database
@@ -548,9 +549,10 @@
      try {
        DatabaseEntry indexData = new DatabaseEntry();
        entryCacheDataBinding.objectToEntry(entryCacheIndex, indexData);
        DatabaseEntry indexKey = new DatabaseEntry(INDEXKEY.getBytes("UTF-8"));
        if (OperationStatus.SUCCESS !=
            entryCacheDB.put(null, indexKey, indexData)) {
          DatabaseEntry indexKey =
            new DatabaseEntry(INDEXKEY.getBytes("UTF-8"));
          if (OperationStatus.SUCCESS != entryCacheDB.put(null, indexKey,
              indexData)) {
          throw new Exception();
        }
      } catch (Exception e) {
@@ -594,6 +596,7 @@
      // That is ok, JE verification and repair on startup should take care of
      // this so if there are any unrecoverable errors during next startup
      // and we are unable to handle and cleanup them we will log errors then.
      }
    } finally {
      cacheWriteLock.unlock();
    }
@@ -784,8 +787,10 @@
   * {@inheritDoc}
   */
  public void clear() {
    cacheWriteLock.lock();
    try {
    dnMap.clear();
    backendMap.clear();
@@ -798,19 +803,20 @@
        entryCacheEnv.truncateDatabase(null, ENTRYCACHEDBNAME, false);
        entryCacheEnv.truncateDatabase(null, INDEXCLASSDBNAME, false);
        entryCacheEnv.cleanLog();
        entryCacheDB = entryCacheEnv.openDatabase(null,
            ENTRYCACHEDBNAME, entryCacheDBConfig);
          entryCacheDB = entryCacheEnv.openDatabase(null, ENTRYCACHEDBNAME,
            entryCacheDBConfig);
        entryCacheClassDB = entryCacheEnv.openDatabase(null,
            INDEXCLASSDBNAME, entryCacheDBConfig);
        // Instantiate the class catalog
        classCatalog = new StoredClassCatalog(entryCacheClassDB);
        entryCacheDataBinding =
            new SerialBinding(classCatalog, FileSystemEntryCacheIndex.class);
          entryCacheDataBinding = new SerialBinding(classCatalog,
            FileSystemEntryCacheIndex.class);
      }
    } catch (Exception e) {
      if (debugEnabled()) {
        TRACER.debugCaught(DebugLogLevel.ERROR, e);
      }
      }
    } finally {
      cacheWriteLock.unlock();
    }
@@ -823,6 +829,7 @@
    cacheWriteLock.lock();
    try {
    Map<Long,DN> backendEntriesMap = backendMap.get(backend);
    try {
@@ -837,14 +844,15 @@
      while (backendEntriesIterator.hasNext()) {
        Long entryID = backendEntriesIterator.next();
        DN entryDN = backendEntriesMap.get(entryID);
        entryCacheDB.delete(null,
            new DatabaseEntry(entryDN.toNormalizedString().getBytes("UTF-8")));
          entryCacheDB.delete(null, new DatabaseEntry(
            entryDN.toNormalizedString().getBytes("UTF-8")));
        backendEntriesIterator.remove();
        dnMap.remove(entryDN);
        // This can take a while, so we'll periodically release and re-acquire
        // the lock in case anyone else is waiting on it so this doesn't become
        // a stop-the-world event as far as the cache is concerned.
          // This can take a while, so we'll periodically release and
          // re-acquire the lock in case anyone else is waiting on it
          // so this doesn't become a stop-the-world event as far as
          // the cache is concerned.
        entriesExamined++;
        if ((entriesExamined % 1000) == 0) {
          cacheWriteLock.unlock();
@@ -859,6 +867,7 @@
      if (debugEnabled()) {
        TRACER.debugCaught(DebugLogLevel.ERROR, e);
      }
      }
    } finally {
      cacheWriteLock.unlock();
    }
opends/src/server/org/opends/server/extensions/SoftReferenceEntryCache.java
@@ -109,7 +109,6 @@
  {
    super();
    dnMap = new ConcurrentHashMap<DN,SoftReference<CacheEntry>>();
    idMap = new ConcurrentHashMap<Backend,
                     ConcurrentHashMap<Long,SoftReference<CacheEntry>>>();
@@ -118,10 +117,6 @@
    setIncludeFilters(new HashSet<SearchFilter>());
    setLockTimeout(LockManager.DEFAULT_TIMEOUT);
    referenceQueue = new ReferenceQueue<CacheEntry>();
    cleanerThread = new Thread(this, "Soft Reference Entry Cache Cleaner");
    cleanerThread.setDaemon(true);
    cleanerThread.start();
  }
@@ -134,6 +129,10 @@
      )
      throws ConfigException, InitializationException
  {
    cleanerThread = new Thread(this, "Soft Reference Entry Cache Cleaner");
    cleanerThread.setDaemon(true);
    cleanerThread.start();
    registeredConfiguration = configuration;
    configuration.addSoftReferenceChangeListener (this);