opendj3-server-dev/src/server/org/opends/server/replication/server/ECLServerHandler.java
@@ -552,12 +552,11 @@ // Read the CNIndexDB to see whether it contains startChangeNumber DBCursor<ChangeNumberIndexRecord> cursor = cnIndexDB.getCursorFrom(startChangeNumber); final ChangeNumberIndexRecord startRecord = cursor.getRecord(); if (startRecord != null) if (cursor.next()) { // found the provided startChangeNumber, let's return it cnIndexDBCursor = cursor; return startRecord.getPreviousCookie(); return cursor.getRecord().getPreviousCookie(); } close(cursor); @@ -576,8 +575,7 @@ if (startChangeNumber < oldestChangeNumber) { cursor = cnIndexDB.getCursorFrom(oldestChangeNumber); final ChangeNumberIndexRecord oldestRecord = cursor.getRecord(); if (oldestRecord == null) if (!cursor.next()) { // This should not happen close(cursor); @@ -586,7 +584,7 @@ } cnIndexDBCursor = cursor; return oldestRecord.getPreviousCookie(); return cursor.getRecord().getPreviousCookie(); } else if (startChangeNumber <= newestChangeNumber) { @@ -617,6 +615,7 @@ { DBCursor<ChangeNumberIndexRecord> cursor = cnIndexDB.getCursorFrom(startChangeNumber); cursor.next(); if (cursor.getRecord() == null) { close(cursor); opendj3-server-dev/src/server/org/opends/server/replication/server/changelog/api/ChangeNumberIndexDB.java
@@ -89,7 +89,7 @@ * * @param startChangeNumber * The position where the iterator must start. * @return a new ReplicationIterator that allows to browse this DB managed by * @return a new DBCursor that allows to browse this DB managed by * this object and starting at the position defined by a given * changeNumber. * @throws ChangelogException opendj3-server-dev/src/server/org/opends/server/replication/server/changelog/je/JEChangeNumberIndexDBCursor.java
@@ -42,7 +42,13 @@ private DraftCNDBCursor draftCNDbCursor; /** * Creates a new ReplicationIterator. All created iterator must be released by * As underlying cursor is already pointing to a record at start, this * indicator allow to shift the pointed record at initialization time. */ private boolean isInitialized = false; /** * Creates a new DB Cursor. All created iterator must be released by * the caller using the {@link #close()} method. * * @param db @@ -64,7 +70,7 @@ { try { return this.draftCNDbCursor.currentRecord(); return isInitialized ? draftCNDbCursor.currentRecord() : null; } catch (Exception e) { @@ -79,8 +85,16 @@ { if (draftCNDbCursor != null) { if (!isInitialized) { isInitialized = true; return draftCNDbCursor.currentRecord() != null; } else { return draftCNDbCursor.next(); } } return false; } opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/replication/server/changelog/je/JEChangeNumberIndexDBTest.java
@@ -123,6 +123,7 @@ DBCursor<ChangeNumberIndexRecord> cursor = cnIndexDB.getCursorFrom(oldestCN); try { assertTrue(cursor.next()); assertEqualTo(cursor.getRecord(), csns[0], baseDN1, cookies.get(0)); assertTrue(cursor.next()); assertEqualTo(cursor.getRecord(), csns[1], baseDN2, cookies.get(1)); @@ -282,6 +283,7 @@ DBCursor<ChangeNumberIndexRecord> cursor = cnIndexDB.getCursorFrom(changeNumber); try { cursor.next(); return cursor.getRecord().getPreviousCookie(); } finally @@ -297,10 +299,10 @@ { for (int i = 0; i < cns.length; i++) { assertTrue(cursor.next()); assertEquals(cursor.getRecord().getChangeNumber(), cns[i]); final boolean isNotLast = i + 1 < cns.length; assertEquals(cursor.next(), isNotLast); } assertFalse(cursor.next()); } finally {