Skip to content

Commit

Permalink
Partial fix for DIRSERVER-1728: core-avl
Browse files Browse the repository at this point in the history
  • Loading branch information
elecharny committed Aug 19, 2024
1 parent 0c6d560 commit 4c8bdb5
Show file tree
Hide file tree
Showing 8 changed files with 59 additions and 61 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ public byte[] serialize( ArrayTree<E> tree )
}
catch ( IOException e )
{
LOG_CURSOR.error( I18n.err( I18n.ERR_752_CANNOT_SERIALIZE_TREE, e.getMessage() ) );
LOG_CURSOR.error( I18n.err( I18n.ERR_03011_CANNOT_SERIALIZE_TREE, e.getMessage() ) );
}

return data;
Expand All @@ -142,7 +142,7 @@ public ArrayTree<E> deserialize( byte[] data ) throws IOException
{
if ( ( data == null ) || ( data.length == 0 ) )
{
throw new IOException( I18n.err( I18n.ERR_439 ) );
throw new IOException( I18n.err( I18n.ERR_03004_NULL_OR_EMPTY_DATA_ARRAY ) );
}

if ( ( data.length == 1 ) && ( data[0] == 0 ) )
Expand All @@ -159,8 +159,8 @@ public ArrayTree<E> deserialize( byte[] data ) throws IOException

if ( startByte != 0 )
{
LOG_CURSOR.error( I18n.err( I18n.ERR_440 ) );
throw new IOException( I18n.err( I18n.ERR_440 ) );
LOG_CURSOR.error( I18n.err( I18n.ERR_03005_WRONG_ARRAY_SERIALIZED_DATA_FORMAT ) );
throw new IOException( I18n.err( I18n.ERR_03005_WRONG_ARRAY_SERIALIZED_DATA_FORMAT ) );
}

int size = din.readInt();
Expand All @@ -185,7 +185,7 @@ public ArrayTree<E> deserialize( byte[] data ) throws IOException
}
catch ( NullPointerException npe )
{
LOG_CURSOR.error( I18n.err( I18n.ERR_441, Strings.dumpBytes( data ) ) );
LOG_CURSOR.error( I18n.err( I18n.ERR_03006_BAD_TREE, Strings.dumpBytes( data ) ) );
throw npe;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ public AvlTree<E> deserialize( byte[] data ) throws IOException
{
if ( data == null || data.length == 0 )
{
throw new IOException( I18n.err( I18n.ERR_439 ) );
throw new IOException( I18n.err( I18n.ERR_03004_NULL_OR_EMPTY_DATA_ARRAY ) );
}

if ( data.length == 1 && data[0] == 0 )
Expand All @@ -180,7 +180,7 @@ public AvlTree<E> deserialize( byte[] data ) throws IOException

if ( startByte != 0 )
{
throw new IOException( I18n.err( I18n.ERR_443 ) );
throw new IOException( I18n.err( I18n.ERR_03007_WRONG_AVL_TREE_SERIALIZED_DATA_FORMAT ) );
}

int size = din.readInt();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ public int getSize()

public K insert( K key )
{
throw new UnsupportedOperationException( I18n.err( I18n.ERR_444 ) );
throw new UnsupportedOperationException( I18n.err( I18n.ERR_03008_SINGLETON_AVL_TREE_CHANGE_FORBIDDEN ) );
}


Expand All @@ -189,6 +189,6 @@ public void printTree()

public K remove( K key )
{
throw new UnsupportedOperationException( I18n.err( I18n.ERR_444 ) );
throw new UnsupportedOperationException( I18n.err( I18n.ERR_03008_SINGLETON_AVL_TREE_CHANGE_FORBIDDEN ) );
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public Object deserialize( byte[] bytes ) throws IOException
}
catch ( ClassNotFoundException e )
{
IOException ioe = new IOException( I18n.err( I18n.ERR_445 ) );
IOException ioe = new IOException( I18n.err( I18n.ERR_03009_COULD_NOT_FIND_CLASS ) );
ioe.initCause( e );
throw ioe;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,13 +88,13 @@ public boolean available()

public void beforeKey( K key ) throws Exception
{
throw new UnsupportedOperationException( I18n.err( I18n.ERR_446 ) );
throw new UnsupportedOperationException( I18n.err( I18n.ERR_03010_CURSOR_LOCK_KEY ) );
}


public void afterKey( K key ) throws Exception
{
throw new UnsupportedOperationException( I18n.err( I18n.ERR_446 ) );
throw new UnsupportedOperationException( I18n.err( I18n.ERR_03010_CURSOR_LOCK_KEY ) );
}


Expand All @@ -103,7 +103,7 @@ public void beforeValue( K key, V value ) throws Exception
checkNotClosed();
if ( key != null && !key.equals( this.key ) )
{
throw new UnsupportedOperationException( I18n.err( I18n.ERR_446 ) );
throw new UnsupportedOperationException( I18n.err( I18n.ERR_03010_CURSOR_LOCK_KEY ) );
}

wrapped.before( value );
Expand All @@ -116,7 +116,7 @@ public void afterValue( K key, V value ) throws Exception
checkNotClosed();
if ( key != null && !key.equals( this.key ) )
{
throw new UnsupportedOperationException( I18n.err( I18n.ERR_446 ) );
throw new UnsupportedOperationException( I18n.err( I18n.ERR_03010_CURSOR_LOCK_KEY ) );
}

wrapped.after( value );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public SingletonOrOrderedSet( V singleton )
{
if ( singleton == null )
{
throw new IllegalArgumentException( I18n.err( I18n.ERR_447 ) );
throw new IllegalArgumentException( I18n.err( I18n.ERR_03012_NULL_SINGLETON ) );
}

this.singleton = singleton;
Expand All @@ -60,7 +60,7 @@ public SingletonOrOrderedSet( AvlTree<V> orderedSet )
{
if ( orderedSet == null )
{
throw new IllegalArgumentException( I18n.err( I18n.ERR_448 ) );
throw new IllegalArgumentException( I18n.err( I18n.ERR_03013_NULL_ORDERED_SET ) );
}

this.orderedSet = orderedSet;
Expand Down Expand Up @@ -102,7 +102,7 @@ public V getSingleton()
return singleton;
}

throw new RuntimeException( I18n.err( I18n.ERR_449 ) );
throw new RuntimeException( I18n.err( I18n.ERR_03014_REQUEST_SINGLETON_FORBIDDEN ) );
}


Expand All @@ -116,12 +116,12 @@ public V setSingleton( V singleton )
{
if ( singleton == null )
{
throw new IllegalArgumentException( I18n.err( I18n.ERR_447 ) );
throw new IllegalArgumentException( I18n.err( I18n.ERR_03012_NULL_SINGLETON ) );
}

if ( this.orderedSet != null )
{
throw new RuntimeException( I18n.err( I18n.ERR_450 ) );
throw new RuntimeException( I18n.err( I18n.ERR_03015_SET_SINGLETON_FORBIDDEN ) );
}

V retval = this.singleton;
Expand All @@ -142,12 +142,12 @@ public AvlTree<V> switchToSingleton( V singleton )
{
if ( singleton == null )
{
throw new IllegalArgumentException( I18n.err( I18n.ERR_447 ) );
throw new IllegalArgumentException( I18n.err( I18n.ERR_03012_NULL_SINGLETON ) );
}

if ( this.singleton != null )
{
throw new RuntimeException( I18n.err( I18n.ERR_451 ) );
throw new RuntimeException( I18n.err( I18n.ERR_03016_ALREADY_IN_SINGLETON_MODE ) );
}

AvlTree<V> retval = this.orderedSet;
Expand All @@ -170,7 +170,7 @@ public AvlTree<V> getOrderedSet()
return orderedSet;
}

throw new RuntimeException( I18n.err( I18n.ERR_452 ) );
throw new RuntimeException( I18n.err( I18n.ERR_03017_CANNOT_GET_ORDERED_SET ) );
}


Expand All @@ -185,12 +185,12 @@ public AvlTree<V> setOrderedSet( AvlTree<V> orderedSet )
{
if ( orderedSet == null )
{
throw new IllegalArgumentException( I18n.err( I18n.ERR_448 ) );
throw new IllegalArgumentException( I18n.err( I18n.ERR_03013_NULL_ORDERED_SET ) );
}

if ( this.singleton != null )
{
throw new RuntimeException( I18n.err( I18n.ERR_453 ) );
throw new RuntimeException( I18n.err( I18n.ERR_03018_CANNOT_SET_ORDERED_SET ) );
}

AvlTree<V> retval = this.orderedSet;
Expand All @@ -211,12 +211,12 @@ public V switchToOrderedSet( AvlTree<V> orderedSet )
{
if ( orderedSet == null )
{
throw new IllegalArgumentException( I18n.err( I18n.ERR_448 ) );
throw new IllegalArgumentException( I18n.err( I18n.ERR_03013_NULL_ORDERED_SET ) );
}

if ( this.orderedSet != null )
{
throw new RuntimeException( I18n.err( I18n.ERR_454 ) );
throw new RuntimeException( I18n.err( I18n.ERR_03019_ALREADY_IN_ORDERED_SET_MODE ) );
}

V retval = this.singleton;
Expand Down
35 changes: 17 additions & 18 deletions i18n/src/main/java/org/apache/directory/server/i18n/I18n.java
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,22 @@ public enum I18n
ERR_03001_NEGATIVE_AVL_LENGTH("ERR_03001_NEGATIVE_AVL_LENGTH"),
ERR_03002_NEGATIVE_NODE_LENGTH("ERR_03002_NEGATIVE_NODE_LENGTH"),
ERR_03003_INVALID_NODE_NUMBER("ERR_03003_INVALID_NODE_NUMBER"),
ERR_03004_NULL_OR_EMPTY_DATA_ARRAY("ERR_03004_NULL_OR_EMPTY_DATA_ARRAY"),
ERR_03005_WRONG_ARRAY_SERIALIZED_DATA_FORMAT("ERR_03005_WRONG_ARRAY_SERIALIZED_DATA_FORMAT"),
ERR_03006_BAD_TREE("ERR_03006_BAD_TREE"),
ERR_03007_WRONG_AVL_TREE_SERIALIZED_DATA_FORMAT("ERR_03007_WRONG_AVL_TREE_SERIALIZED_DATA_FORMAT"),
ERR_03008_SINGLETON_AVL_TREE_CHANGE_FORBIDDEN("ERR_03008_SINGLETON_AVL_TREE_CHANGE_FORBIDDEN"),
ERR_03009_COULD_NOT_FIND_CLASS("ERR_03009_COULD_NOT_FIND_CLASS"),
ERR_03010_CURSOR_LOCK_KEY("ERR_03010_CURSOR_LOCK_KEY"),
ERR_03011_CANNOT_SERIALIZE_TREE("ERR_03011_CANNOT_SERIALIZE_TREE"),
ERR_03012_NULL_SINGLETON("ERR_03012_NULL_SINGLETON"),
ERR_03013_NULL_ORDERED_SET("ERR_03013_NULL_ORDERED_SET"),
ERR_03014_REQUEST_SINGLETON_FORBIDDEN("ERR_03014_REQUEST_SINGLETON_FORBIDDEN"),
ERR_03015_SET_SINGLETON_FORBIDDEN("ERR_03015_SET_SINGLETON_FORBIDDEN"),
ERR_03016_ALREADY_IN_SINGLETON_MODE("ERR_03016_ALREADY_IN_SINGLETON_MODE"),
ERR_03017_CANNOT_GET_ORDERED_SET("ERR_03017_CANNOT_GET_ORDERED_SET"),
ERR_03018_CANNOT_SET_ORDERED_SET("ERR_03018_CANNOT_SET_ORDERED_SET"),
ERR_03019_ALREADY_IN_ORDERED_SET_MODE("ERR_03019_ALREADY_IN_ORDERED_SET_MODE"),

// apacheds-core-constants errors 4000 - 4999

Expand Down Expand Up @@ -551,22 +567,6 @@ public enum I18n
ERR_434("ERR_434"),
ERR_435("ERR_435"),
ERR_438("ERR_438"),
ERR_439("ERR_439"),
ERR_440("ERR_440"),
ERR_441("ERR_441"),
// ERR_442( "ERR_442" ),
ERR_443("ERR_443"),
ERR_444("ERR_444"),
ERR_445("ERR_445"),
ERR_446("ERR_446"),
ERR_447("ERR_447"),
ERR_448("ERR_448"),
ERR_449("ERR_449"),
ERR_450("ERR_450"),
ERR_451("ERR_451"),
ERR_452("ERR_452"),
ERR_453("ERR_453"),
ERR_454("ERR_454"),
// ERR_457( "ERR_457" ),
// ERR_458( "ERR_458" ),
// ERR_459( "ERR_459" ),
Expand Down Expand Up @@ -855,8 +855,7 @@ public enum I18n
ERR_748("ERR_748"),
ERR_749("ERR_749"),
ERR_750("ERR_750"),
ERR_751("ERR_751"),
ERR_752_CANNOT_SERIALIZE_TREE("ERR_752_CANNOT_SERIALIZE_TREE");
ERR_751("ERR_751");


private static final ResourceBundle ERR_BUNDLE = ResourceBundle
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,22 @@ ERR_03000_NEGATIVE_AVL_NODE_COUNT=The number of node for the deserialized AVL is
ERR_03001_NEGATIVE_AVL_LENGTH=The AVL tree has a negative length
ERR_03002_NEGATIVE_NODE_LENGTH=The AVL Node length is negative
ERR_03003_INVALID_NODE_NUMBER=The Node number is not valid: {0}, {1} expected
ERR_03004_NULL_OR_EMPTY_DATA_ARRAY=Null or empty data array is invalid.
ERR_03005_WRONG_ARRAY_SERIALIZED_DATA_FORMAT=wrong array serialized data format
ERR_03006_BAD_TREE=Bad tree : [{0}]
ERR_03007_WRONG_AVL_TREE_SERIALIZED_DATA_FORMAT=wrong AvlTree serialized data format
ERR_03008_SINGLETON_AVL_TREE_CHANGE_FORBIDDEN=This singleton AvlTree does not support changes since the behavior of alterations on a singleton are undefined.
ERR_03009_COULD_NOT_FIND_CLASS=Could not find class
ERR_03010_CURSOR_LOCK_KEY=This cursor locks down the key so keywise advances are not allowed.
ERR_03011_CANNOT_SERIALIZE_TREE=Error while serializing the tree: {0}
ERR_03012_NULL_SINGLETON=singleton must not be null
ERR_03013_NULL_ORDERED_SET=orderedSet must not be null
ERR_03014_REQUEST_SINGLETON_FORBIDDEN=Cannot request singleton when in ordered set mode.
ERR_03015_SET_SINGLETON_FORBIDDEN=Cannot set a singleton when using multiple values: use switchToSingleton()
ERR_03016_ALREADY_IN_SINGLETON_MODE=Already in singleton mode.
ERR_03017_CANNOT_GET_ORDERED_SET=Cannot get ordered set in singleton mode.
ERR_03018_CANNOT_SET_ORDERED_SET=Cannot set a orderedSet when in singleton mode: use switchToSingleValue()
ERR_03019_ALREADY_IN_ORDERED_SET_MODE=Already in ordered set mode.

# apacheds-core-constants errors 4000 - 4999

Expand Down Expand Up @@ -539,22 +555,6 @@ ERR_433=Got more than one syntaxChecker for oid of {0}
ERR_434=Attribute of second rdn in dn ''{0}'' expected to be CN oid of {1} but was {2}
ERR_435=Got more than one result for the entity name: {0}
ERR_438=Bad serialization, tree : [{0}]
ERR_439=Null or empty data array is invalid.
ERR_440=wrong array serialized data format
ERR_441=Bad tree : [{0}]
# ERR_442=
ERR_443=wrong AvlTree serialized data format
ERR_444=This singleton AvlTree does not support changes since the behavior of alterations on a singleton are undefined.
ERR_445=Could not find class
ERR_446=This cursor locks down the key so keywise advances are not allowed.
ERR_447=singleton must not be null
ERR_448=orderedSet must not be null
ERR_449=Cannot request singleton when in ordered set mode.
ERR_450=Cannot set a singleton when using multiple values: use switchToSingleton()
ERR_451=Already in singleton mode.
ERR_452=Cannot get ordered set in singleton mode.
ERR_453=Cannot set a orderedSet when in singleton mode: use switchToSingleValue()
ERR_454=Already in ordered set mode.
# ERR_457=
# ERR_458=
# ERR_459=
Expand Down Expand Up @@ -844,4 +844,3 @@ ERR_748=Invalid log file bufferSize/ max size is sepcified bufferSize {0} logFil
ERR_749=Log Scanner is already closed
ERR_750=Log content is invalid
ERR_751=Invalid TrustManager Class {0}
ERR_752_CANNOT_SERIALIZE_TREE=Error while serializing the tree: {0}

0 comments on commit 4c8bdb5

Please sign in to comment.