directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r1033528 - in /directory: apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/options/ apacheds/trunk/kerberos-codec/src/test/java/org/apache/directory/shared/kerberos/codec/options/ shared/trunk/ldap/src/...
Date Wed, 10 Nov 2010 15:40:49 GMT
Author: elecharny
Date: Wed Nov 10 15:40:49 2010
New Revision: 1033528

URL: http://svn.apache.org/viewvc?rev=1033528&view=rev
Log:
Some more fixes for BitString (the last ones, I hope !)

Modified:
    directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/options/Options.java
    directory/apacheds/trunk/kerberos-codec/src/test/java/org/apache/directory/shared/kerberos/codec/options/OptionsTest.java
    directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/asn1/ber/tlv/Value.java
    directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/asn1/primitives/BitString.java

Modified: directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/options/Options.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/options/Options.java?rev=1033528&r1=1033527&r2=1033528&view=diff
==============================================================================
--- directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/options/Options.java
(original)
+++ directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/options/Options.java
Wed Nov 10 15:40:49 2010
@@ -61,7 +61,7 @@ public abstract class Options extends Bi
      */
     public boolean get( int index )
     {
-        if ( index >= size() )
+        if ( ( index < 0 ) || ( index >= size() ) )
         {
             throw new ArrayIndexOutOfBoundsException();
         }
@@ -77,7 +77,7 @@ public abstract class Options extends Bi
      */
     public void set( int index )
     {
-        if ( ( index < 0 ) || ( index > size() ) )
+        if ( ( index < 0 ) || ( index >= size() ) )
         {
             return;
         }
@@ -93,7 +93,7 @@ public abstract class Options extends Bi
      */
     public void clear( int index )
     {
-        if ( ( index < 0 ) || ( index > size() ) )
+        if ( ( index < 0 ) || ( index >= size() ) )
         {
             return;
         }

Modified: directory/apacheds/trunk/kerberos-codec/src/test/java/org/apache/directory/shared/kerberos/codec/options/OptionsTest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/kerberos-codec/src/test/java/org/apache/directory/shared/kerberos/codec/options/OptionsTest.java?rev=1033528&r1=1033527&r2=1033528&view=diff
==============================================================================
--- directory/apacheds/trunk/kerberos-codec/src/test/java/org/apache/directory/shared/kerberos/codec/options/OptionsTest.java
(original)
+++ directory/apacheds/trunk/kerberos-codec/src/test/java/org/apache/directory/shared/kerberos/codec/options/OptionsTest.java
Wed Nov 10 15:40:49 2010
@@ -47,11 +47,11 @@ public class OptionsTest
         MyOptions myOptions = new MyOptions(); 
         
         // Set the bits 10-0100 1010-1100 0000-0110
-        myOptions.setBytes( new byte[]{ (byte)0x24, (byte)0xAC, 0x06} );
+        myOptions.setBytes( new byte[]{ 0x02, (byte)0x92, (byte)0xB0, 0x18} );
 
         assertEquals( "1001001010110000000110", myOptions.toString() );
-        assertTrue( myOptions.get( 21 ) );
-        assertFalse( myOptions.get( 20 ) );
+        assertFalse( myOptions.get( 21 ) );
+        assertTrue( myOptions.get( 20 ) );
         
         try
         {

Modified: directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/asn1/ber/tlv/Value.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/asn1/ber/tlv/Value.java?rev=1033528&r1=1033527&r2=1033528&view=diff
==============================================================================
--- directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/asn1/ber/tlv/Value.java
(original)
+++ directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/asn1/ber/tlv/Value.java
Wed Nov 10 15:40:49 2010
@@ -682,10 +682,11 @@ public class Value implements Serializab
 
             // The BitString length. We add one byte for the unused number 
             // of bits
-            int length = bitString.size() + 1;
+            byte[] bytes = bitString.getData(); 
+            int length = bytes.length;
 
             buffer.put( TLV.getBytes( length ) );
-            buffer.put( bitString.getData() );
+            buffer.put( bytes );
         }
         catch ( BufferOverflowException boe )
         {

Modified: directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/asn1/primitives/BitString.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/asn1/primitives/BitString.java?rev=1033528&r1=1033527&r2=1033528&view=diff
==============================================================================
--- directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/asn1/primitives/BitString.java
(original)
+++ directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/asn1/primitives/BitString.java
Wed Nov 10 15:40:49 2010
@@ -265,7 +265,7 @@ public class BitString implements Serial
     {
         StringBuilder sb = new StringBuilder();
 
-        for ( int i = nbBits-1; i >= 0; i-- )
+        for ( int i = 0; i < nbBits; i++ )
         {
             if ( getBit( i ) )
             {



Mime
View raw message