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

Jean-Noel Rouvignac
04.47.2013 513eb83896bf4654aa0e3628c2666e307712a8cc
ChangeNumberIndexer.java:
In run(), made sure all cursors are properly closed, even in case of a RuntimeException terminating the thread.
Moved resetNextChangeForInsertDBCursor() out of removeAllCursors().
In removeAllCursors(), closed the CompositeDBCursor.

ServerHandler.java:
Made shutdownWriter volatile.

JEReplicaDBCursor.java:
Avoided a NullPointerException.

3 files modified
26 ■■■■ changed files
opends/src/server/org/opends/server/replication/server/ServerHandler.java 4 ●●●● patch | view | raw | blame | history
opends/src/server/org/opends/server/replication/server/changelog/je/ChangeNumberIndexer.java 14 ●●●● patch | view | raw | blame | history
opends/src/server/org/opends/server/replication/server/changelog/je/JEReplicaDBCursor.java 8 ●●●●● patch | view | raw | blame | history
opends/src/server/org/opends/server/replication/server/ServerHandler.java
@@ -145,7 +145,7 @@
  /**
   * The associated ServerWriter that sends messages to the remote server.
   */
  protected ServerWriter writer = null;
  protected ServerWriter writer;
  /**
   * The associated ServerReader that receives messages from the remote server.
@@ -202,7 +202,7 @@
  /**
   * Set when ServerWriter is stopping.
   */
  protected boolean shutdownWriter = false;
  protected volatile boolean shutdownWriter = false;
  /**
   * Weight of this remote server.
opends/src/server/org/opends/server/replication/server/changelog/je/ChangeNumberIndexer.java
@@ -365,6 +365,7 @@
          if (doClear.get())
          {
            removeAllCursors();
            resetNextChangeForInsertDBCursor();
            // No need to use CAS here because it is only for unit tests and at
            // this point all will have been cleaned up anyway.
            doClear.set(false);
@@ -434,7 +435,6 @@
          Thread.currentThread().interrupt();
        }
      }
      removeAllCursors();
    }
    catch (ChangelogException e)
    {
@@ -448,6 +448,10 @@
        TRACER.debugCaught(DebugLogLevel.ERROR, e);
      // TODO JNR error message i18n
    }
    finally
    {
      removeAllCursors();
    }
  }
  private void moveForwardMediumConsistencyPoint(final CSN csn, final DN baseDN)
@@ -467,15 +471,19 @@
    }
  }
  private void removeAllCursors() throws ChangelogException
  private void removeAllCursors()
  {
    if (nextChangeForInsertDBCursor != null)
    {
      nextChangeForInsertDBCursor.close();
      nextChangeForInsertDBCursor = null;
    }
    for (Map<Integer, DBCursor<UpdateMsg>> map : allCursors.values())
    {
      StaticUtils.close(map.values());
    }
    allCursors.clear();
    newCursors.clear();
    resetNextChangeForInsertDBCursor();
  }
  private void removeCursor(final DN baseDN, final CSN csn)
opends/src/server/org/opends/server/replication/server/changelog/je/JEReplicaDBCursor.java
@@ -96,7 +96,15 @@
  @Override
  public boolean next() throws ChangelogException
  {
    if (cursor != null)
    {
    currentChange = cursor.next();
    }
    else
    {
      currentChange = null;
    }
    if (currentChange != null)
    {