Return-Path: X-Original-To: apmail-directory-commits-archive@www.apache.org Delivered-To: apmail-directory-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id CA03998FD for ; Tue, 11 Oct 2011 11:18:41 +0000 (UTC) Received: (qmail 58485 invoked by uid 500); 11 Oct 2011 11:18:41 -0000 Delivered-To: apmail-directory-commits-archive@directory.apache.org Received: (qmail 58425 invoked by uid 500); 11 Oct 2011 11:18:41 -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 58411 invoked by uid 99); 11 Oct 2011 11:18:41 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 11 Oct 2011 11:18:41 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED 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, 11 Oct 2011 11:18:37 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id 562F4238897D for ; Tue, 11 Oct 2011 11:18:15 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1181716 - in /directory/apacheds/trunk/jdbm/src/main/java/jdbm: btree/BTree.java helper/ActionContext.java helper/ActionVersioning.java helper/ExplicitList.java helper/LRUCache.java recman/SnapshotRecordManager.java Date: Tue, 11 Oct 2011 11:18:15 -0000 To: commits@directory.apache.org From: saya@apache.org X-Mailer: svnmailer-1.0.8-patched Message-Id: <20111011111815.562F4238897D@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: saya Date: Tue Oct 11 11:18:14 2011 New Revision: 1181716 URL: http://svn.apache.org/viewvc?rev=1181716&view=rev Log: Modify jdbm files to use IllegalStateException rather than asserts. Modified: directory/apacheds/trunk/jdbm/src/main/java/jdbm/btree/BTree.java directory/apacheds/trunk/jdbm/src/main/java/jdbm/helper/ActionContext.java directory/apacheds/trunk/jdbm/src/main/java/jdbm/helper/ActionVersioning.java directory/apacheds/trunk/jdbm/src/main/java/jdbm/helper/ExplicitList.java directory/apacheds/trunk/jdbm/src/main/java/jdbm/helper/LRUCache.java directory/apacheds/trunk/jdbm/src/main/java/jdbm/recman/SnapshotRecordManager.java Modified: directory/apacheds/trunk/jdbm/src/main/java/jdbm/btree/BTree.java URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/jdbm/src/main/java/jdbm/btree/BTree.java?rev=1181716&r1=1181715&r2=1181716&view=diff ============================================================================== --- directory/apacheds/trunk/jdbm/src/main/java/jdbm/btree/BTree.java (original) +++ directory/apacheds/trunk/jdbm/src/main/java/jdbm/btree/BTree.java Tue Oct 11 11:18:14 2011 @@ -743,7 +743,10 @@ public class BTree implements Exte */ BPage getRoot( ) throws IOException { - assert( this.rootId == metaRoot.rootID) : "Stale root id " + this.rootId + " "+ metaRoot.rootID; + if ( rootId != metaRoot.rootID ) + { + throw new IllegalStateException( "Stale root id " + this.rootId + " "+ metaRoot.rootID ); + } if ( this.rootId == 0 ) { @@ -864,7 +867,6 @@ public class BTree implements Exte { if ( context != null ) { - assert( isActionCapable == true ); ( ( ActionRecordManager )recordManager ).setCurrentActionContext( context ); } } @@ -874,7 +876,6 @@ public class BTree implements Exte { if ( context != null ) { - assert( isActionCapable == true ); ( ( ActionRecordManager )recordManager ).unsetCurrentActionContext( context ); } } @@ -897,7 +898,6 @@ public class BTree implements Exte { if ( context != null ) { - assert( isActionCapable ); ( ( ActionRecordManager )recordManager ).endAction( context ); } } @@ -907,7 +907,6 @@ public class BTree implements Exte { if ( context != null ) { - assert( isActionCapable ); ( ( ActionRecordManager )recordManager ).abortAction( context ); } Modified: directory/apacheds/trunk/jdbm/src/main/java/jdbm/helper/ActionContext.java URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/jdbm/src/main/java/jdbm/helper/ActionContext.java?rev=1181716&r1=1181715&r2=1181716&view=diff ============================================================================== --- directory/apacheds/trunk/jdbm/src/main/java/jdbm/helper/ActionContext.java (original) +++ directory/apacheds/trunk/jdbm/src/main/java/jdbm/helper/ActionContext.java Tue Oct 11 11:18:14 2011 @@ -45,7 +45,11 @@ public class ActionContext public void endAction() { - assert( version != null ) : "Unexpected action state during endAction: " + this; + if ( version == null ) + { + throw new IllegalStateException( "Unexpected action state during endAction: " + this ); + } + version = null; } Modified: directory/apacheds/trunk/jdbm/src/main/java/jdbm/helper/ActionVersioning.java URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/jdbm/src/main/java/jdbm/helper/ActionVersioning.java?rev=1181716&r1=1181715&r2=1181716&view=diff ============================================================================== --- directory/apacheds/trunk/jdbm/src/main/java/jdbm/helper/ActionVersioning.java (original) +++ directory/apacheds/trunk/jdbm/src/main/java/jdbm/helper/ActionVersioning.java Tue Oct 11 11:18:14 2011 @@ -153,7 +153,11 @@ public class ActionVersioning { long numActions = version.getNumActions().decrementAndGet(); - assert( numActions >= 0 ) : "NumActions zero when read action is ended : " + version; + if ( numActions < 0 ) + { + throw new IllegalStateException( "NumActions zero when read action is ended : " + version ); + } + if ( ( numActions > 0 ) || ( version == readReference.get() ) ) { Modified: directory/apacheds/trunk/jdbm/src/main/java/jdbm/helper/ExplicitList.java URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/jdbm/src/main/java/jdbm/helper/ExplicitList.java?rev=1181716&r1=1181715&r2=1181716&view=diff ============================================================================== --- directory/apacheds/trunk/jdbm/src/main/java/jdbm/helper/ExplicitList.java (original) +++ directory/apacheds/trunk/jdbm/src/main/java/jdbm/helper/ExplicitList.java Tue Oct 11 11:18:14 2011 @@ -75,7 +75,11 @@ public class ExplicitList public void remove() { - assert( isLinked() ) : "Trying to remove from list an unlinked link"; + if ( isLinked() == false ) + { + throw new IllegalStateException( "Trying to remove from list an unlinked link" ); + } + this.getPrev().setNext( this.getNext() ); this.getNext().setPrev( this.getPrev() ); this.reset(); @@ -84,7 +88,11 @@ public class ExplicitList public void addAfter( Link after ) { - assert( this.isUnLinked() ) : "Trying to add to list already linked link: " + this; + if ( this.isUnLinked() == false ) + { + throw new IllegalStateException( "Trying to add to list already linked link: " + this ); + } + after.getNext().setPrev( this ); this.setNext( after.getNext() ); after.setNext( this ); @@ -94,7 +102,11 @@ public class ExplicitList public void addBefore( Link before ) { - assert( this.isUnLinked() ) : "Trying to add to list already linked link: " + this; + if ( this.isUnLinked() == false ) + { + throw new IllegalStateException( "Trying to add to list already linked link: " + this ); + } + before.getPrev().setNext( this ); this.setPrev( before.getPrev() ); before.setPrev( this ); @@ -138,7 +150,11 @@ public class ExplicitList public void uninit() { - assert ( this.isUnLinked() ) : " Unitializing a still linked entry" + this; + if ( this.isUnLinked() == false ) + { + throw new IllegalStateException( " Unitializing a still linked entry" + this ); + } + element = null; } @@ -164,7 +180,11 @@ public class ExplicitList public void remove( Link link ) { - assert( listSize > 0 ) : "Trying to remove link " + link + " from a list with no elements"; + if ( listSize <= 0 ) + { + throw new IllegalStateException( "Trying to remove link " + link + " from a list with no elements" ); + } + listSize--; link.remove(); } Modified: directory/apacheds/trunk/jdbm/src/main/java/jdbm/helper/LRUCache.java URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/jdbm/src/main/java/jdbm/helper/LRUCache.java?rev=1181716&r1=1181715&r2=1181716&view=diff ============================================================================== --- directory/apacheds/trunk/jdbm/src/main/java/jdbm/helper/LRUCache.java (original) +++ directory/apacheds/trunk/jdbm/src/main/java/jdbm/helper/LRUCache.java Tue Oct 11 11:18:14 2011 @@ -238,8 +238,11 @@ public class LRUCache if ( !entry.isCurrentVersion() ) { - assert( entry.isNeverReplace() == false ) : " Non current entry should not have neverReplace set " + entry; - + if ( entry.isNeverReplace() == true ) + { + throw new IllegalStateException( " Non current entry should not have neverReplace set " + entry ); + } + entry.setNeverReplace(); CacheEntry newEntry = null; @@ -293,7 +296,7 @@ public class LRUCache // FALLTHROUGH default: - assert ( false ): "Unknown cache entry state: " + entry ; + throw new IllegalStateException( "Unknown cache entry state: " + entry ) ; } } else @@ -414,7 +417,10 @@ public class LRUCache this.cacheMisses++; - assert( entry.isNeverReplace() == false ) : "Non Current Entry has neverReplace set to true:" + entry; + if ( entry.isNeverReplace() == true ) + { + throw new IllegalStateException( "Non Current Entry has neverReplace set to true:" + entry ); + } entry.setNeverReplace(); CacheEntry newEntry = null; @@ -466,7 +472,7 @@ public class LRUCache break; default: - assert ( false ) : "Unknown cache entry state: " + entry; + throw new IllegalStateException( "Unknown cache entry state: " + entry ); } } else @@ -569,7 +575,10 @@ public class LRUCache } else { - assert( entry.isCurrentVersion() ) : "Entry not at expected version: " + entry ; + if ( entry.isCurrentVersion() == false ) + { + throw new IllegalStateException( "Entry not at expected version: " + entry ); + } // Entry already at current version. Just update the value entry.setAsCurrentVersion( value, newVersion ); @@ -650,15 +659,19 @@ public class LRUCache if ( curEntry.getState() != EntryState.ENTRY_READY ) { - assert( curEntry == head ) : "Unexpected state for entry: " + curEntry; + if ( curEntry != head ) + { + throw new IllegalStateException( "Unexpected state for entry: " + curEntry ); + } + curLink = curLink.getNext(); continue; } if ( curStartVersion != 0 && ( curEntry.getEndVersion() > curStartVersion ) ) { - assert( false ) : "Unexpected version number for entry. curStartVersion: " - + curStartVersion + " entry: " + curEntry; + throw new IllegalStateException( "Unexpected version number for entry. curStartVersion: " + + curStartVersion + " entry: " + curEntry ); } curStartVersion = curEntry.getStartVersion(); @@ -686,7 +699,7 @@ public class LRUCache if ( value == null && mustFind == true ) { - assert( false ) : "Traversed all versions and could not find cache entry"; + throw new IllegalStateException( "Traversed all versions and could not find cache entry" ); } return value; @@ -937,14 +950,26 @@ public class LRUCache endVersion = Long.MAX_VALUE; stateCondition = null; - assert ( numWaiters == 0 ) : "Numwaiters is not zero when entry is newly initialized: " + this; + + if ( numWaiters != 0 ) + { + throw new IllegalStateException( "Numwaiters is not zero when entry is newly initialized: " + this ); + } + state = EntryState.ENTRY_INITIAL; - assert ( versionsLink.isUnLinked() == true ); + if ( versionsLink.isUnLinked() == false ) + { + throw new IllegalStateException( "Versions link is still linked when entry is initialized" ); + } + hashIndex = hash( key ) & ( numBuckets - 1 ); - assert( neverReplace == false ) : "Neverreplace is true when entry is newly intialized:" + this; + if ( neverReplace == true ) + { + throw new IllegalStateException( "Neverreplace is true when entry is newly intialized:" + this ); + } } public void setNeverReplace() @@ -1006,7 +1031,11 @@ public class LRUCache public void decrementWaiters() { - assert ( numWaiters > 0 ) : "Unexpected num waiters for entry:" + this; + if ( numWaiters <= 0 ) + { + throw new IllegalStateException( "Unexpected num waiters for entry:" + this ); + } + numWaiters--; } @@ -1223,9 +1252,11 @@ public class LRUCache { break; } - - assert( victimEntry.getKey() != null ) : - "Snapshot victimEntry doesnt have key set:" + victimEntry ; + + if ( victimEntry.getKey() == null ) + { + throw new IllegalStateException( "Snapshot victimEntry doesnt have key set:" + victimEntry ); + } if ( victimEntry.isNeverReplace() ) { @@ -1242,8 +1273,10 @@ public class LRUCache continue; } - assert( victimEntry.isEntryFreeable() == true ) : - "Snapshot victimEntry is not freeable:" + victimEntry ; + if ( victimEntry.isEntryFreeable() == false ) + { + throw new IllegalStateException( "Snapshot victimEntry is not freeable:" + victimEntry ); + } int hashChainIndex = buckets[victimEntry.getHashIndex()].indexOf( victimEntry ); Modified: directory/apacheds/trunk/jdbm/src/main/java/jdbm/recman/SnapshotRecordManager.java URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/jdbm/src/main/java/jdbm/recman/SnapshotRecordManager.java?rev=1181716&r1=1181715&r2=1181716&view=diff ============================================================================== --- directory/apacheds/trunk/jdbm/src/main/java/jdbm/recman/SnapshotRecordManager.java (original) +++ directory/apacheds/trunk/jdbm/src/main/java/jdbm/recman/SnapshotRecordManager.java Tue Oct 11 11:18:14 2011 @@ -118,7 +118,12 @@ public class SnapshotRecordManager imple public void setCurrentActionContext( ActionContext context ) { ActionContext actionContext = actionContextVar.get(); - assert( actionContext == null ) : "Action Context Not Null: " + actionContext.getWhoStarted(); + + if ( actionContext != null ) + { + throw new IllegalStateException( "Action Context Not Null: " + actionContext.getWhoStarted() ); + } + actionContextVar.set( context ); } @@ -129,7 +134,13 @@ public class SnapshotRecordManager imple public void unsetCurrentActionContext( ActionContext context ) { ActionContext actionContext = actionContextVar.get(); - assert( actionContext == context ); + + if ( actionContext != context ) + { + throw new IllegalStateException( "Trying to end action context not set in the thread context variable" + context + + " " + actionContext ); + } + actionContextVar.set( null ); } @@ -155,7 +166,7 @@ public class SnapshotRecordManager imple } else { - assert( false ); + throw new IllegalStateException( " Wrong action type " + actionContext ); } unsetCurrentActionContext( actionContext ); @@ -196,7 +207,7 @@ public class SnapshotRecordManager imple } else { - assert( false ); + throw new IllegalStateException( "Wrong action context type " + actionContext ); } unsetCurrentActionContext( actionContext );