Return-Path: Delivered-To: apmail-directory-commits-archive@www.apache.org Received: (qmail 47056 invoked from network); 15 Jul 2008 14:00:51 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 15 Jul 2008 14:00:51 -0000 Received: (qmail 10025 invoked by uid 500); 15 Jul 2008 14:00:51 -0000 Delivered-To: apmail-directory-commits-archive@directory.apache.org Received: (qmail 9976 invoked by uid 500); 15 Jul 2008 14:00:51 -0000 Mailing-List: contact commits-help@directory.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@directory.apache.org Delivered-To: mailing list commits@directory.apache.org Received: (qmail 9967 invoked by uid 99); 15 Jul 2008 14:00:51 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 15 Jul 2008 07:00:51 -0700 X-ASF-Spam-Status: No, hits=-1999.6 required=10.0 tests=ALL_TRUSTED,SUBJECT_FUZZY_TION X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 15 Jul 2008 14:00:06 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id C52022388A26; Tue, 15 Jul 2008 07:00:30 -0700 (PDT) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r676922 - in /directory/apacheds/branches/bigbang/jdbm-store/src: main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/NoDupsCursor.java test/java/org/apache/directory/server/core/partition/impl/btree/jdbm/NoDupsCursorTest.java Date: Tue, 15 Jul 2008 14:00:30 -0000 To: commits@directory.apache.org From: kayyagari@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20080715140030.C52022388A26@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: kayyagari Date: Tue Jul 15 07:00:28 2008 New Revision: 676922 URL: http://svn.apache.org/viewvc?rev=676922&view=rev Log: fixed an issue related to JDBM browser switch happening when calling browser.getPrevious() after calling browser.getNext() Added a test case to verify this Modified: directory/apacheds/branches/bigbang/jdbm-store/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/NoDupsCursor.java directory/apacheds/branches/bigbang/jdbm-store/src/test/java/org/apache/directory/server/core/partition/impl/btree/jdbm/NoDupsCursorTest.java Modified: directory/apacheds/branches/bigbang/jdbm-store/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/NoDupsCursor.java URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/jdbm-store/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/NoDupsCursor.java?rev=676922&r1=676921&r2=676922&view=diff ============================================================================== --- directory/apacheds/branches/bigbang/jdbm-store/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/NoDupsCursor.java (original) +++ directory/apacheds/branches/bigbang/jdbm-store/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/NoDupsCursor.java Tue Jul 15 07:00:28 2008 @@ -179,6 +179,15 @@ if ( browser.getPrevious( jdbmTuple ) ) { + if( returnedTuple.getKey() != null ) + { + if( table.getKeyComparator().compare( + ( K) jdbmTuple.getKey(), ( K) returnedTuple.getKey() ) == 0 ) + { + browser.getPrevious( jdbmTuple ); + } + } + //noinspection unchecked returnedTuple.setKey( ( K ) jdbmTuple.getKey() ); //noinspection unchecked @@ -202,6 +211,15 @@ if ( browser.getNext( jdbmTuple ) ) { + if( returnedTuple.getKey() != null ) + { + if( table.getKeyComparator().compare( + ( K) jdbmTuple.getKey(), ( K) returnedTuple.getKey() ) == 0 ) + { + browser.getNext( jdbmTuple ); + } + } + //noinspection unchecked returnedTuple.setKey( ( K ) jdbmTuple.getKey() ); //noinspection unchecked Modified: directory/apacheds/branches/bigbang/jdbm-store/src/test/java/org/apache/directory/server/core/partition/impl/btree/jdbm/NoDupsCursorTest.java URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/jdbm-store/src/test/java/org/apache/directory/server/core/partition/impl/btree/jdbm/NoDupsCursorTest.java?rev=676922&r1=676921&r2=676922&view=diff ============================================================================== --- directory/apacheds/branches/bigbang/jdbm-store/src/test/java/org/apache/directory/server/core/partition/impl/btree/jdbm/NoDupsCursorTest.java (original) +++ directory/apacheds/branches/bigbang/jdbm-store/src/test/java/org/apache/directory/server/core/partition/impl/btree/jdbm/NoDupsCursorTest.java Tue Jul 15 07:00:28 2008 @@ -184,6 +184,68 @@ @Test + public void testJdbmBrowserSwitch() throws Exception + { + for( int i=1; i < 10; i++ ) + { + table.put( i, i ); + } + + Cursor> cursor = table.cursor(); + + // go to last and call next then previous twice then next + cursor.afterLast(); + assertFalse( cursor.next() ); + assertTrue( cursor.previous() ); + assertEquals( 9, ( int ) cursor.get().getKey() ); + + assertTrue( cursor.previous() ); + assertEquals( 8, ( int ) cursor.get().getKey() ); + + assertTrue( cursor.next() ); + assertEquals( 9, ( int ) cursor.get().getKey() ); + + + // go to last and call previous then next and again previous + cursor.afterLast(); + assertTrue( cursor.previous() ); + assertEquals( 9, ( int ) cursor.get().getKey() ); + + assertTrue( cursor.next() ); + assertEquals( 9, ( int ) cursor.get().getKey() ); + + assertTrue( cursor.previous() ); + assertEquals( 8, ( int ) cursor.get().getKey() ); + + + // go to first and call previous then next twice and again next + cursor.beforeFirst(); + assertFalse( cursor.previous() ); + assertTrue( cursor.next() ); + assertEquals( 1, ( int ) cursor.get().getKey() ); + + assertTrue( cursor.next() ); + assertEquals( 2, ( int ) cursor.get().getKey() ); + + assertTrue( cursor.previous() ); + assertEquals( 1, ( int ) cursor.get().getKey() ); + + + // go to first and call next twice then previous + cursor.beforeFirst(); + assertTrue( cursor.next() ); + assertEquals( 1, ( int ) cursor.get().getKey() ); + + assertTrue( cursor.next() ); + assertEquals( 2, ( int ) cursor.get().getKey() ); + + assertTrue( cursor.previous() ); + assertEquals( 1, ( int ) cursor.get().getKey() ); + + } + + + @Test public void testMiscellaneous() throws Exception { }