directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r637403 - in /directory: apacheds/branches/bigbang/core-entry/src/main/java/org/apache/directory/server/core/entry/ apacheds/branches/bigbang/core-entry/src/test/java/org/apache/directory/server/core/entry/ shared/branches/bigbang/ldap/src/...
Date Sat, 15 Mar 2008 12:33:21 GMT
Author: elecharny
Date: Sat Mar 15 05:33:20 2008
New Revision: 637403

URL: http://svn.apache.org/viewvc?rev=637403&view=rev
Log:
Using FindBugs, and fixed :
o Potential NPE
o Removed useless incrementations
o Added a method in LdapURL to return a copy of the bytes
o Improved the use of Map iterators


Modified:
    directory/apacheds/branches/bigbang/core-entry/src/main/java/org/apache/directory/server/core/entry/DefaultServerAttribute.java
    directory/apacheds/branches/bigbang/core-entry/src/test/java/org/apache/directory/server/core/entry/ServerBinaryValueTest.java
    directory/apacheds/branches/bigbang/core-entry/src/test/java/org/apache/directory/server/core/entry/ServerStringValueTest.java
    directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/codec/LdapResult.java
    directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/codec/extended/operations/GracefulDisconnect.java
    directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/codec/util/LdapURL.java
    directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/entry/Modification.java
    directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/entry/client/ClientBinaryValue.java
    directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/schema/RegexNormalizer.java
    directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/util/StringTools.java

Modified: directory/apacheds/branches/bigbang/core-entry/src/main/java/org/apache/directory/server/core/entry/DefaultServerAttribute.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/core-entry/src/main/java/org/apache/directory/server/core/entry/DefaultServerAttribute.java?rev=637403&r1=637402&r2=637403&view=diff
==============================================================================
--- directory/apacheds/branches/bigbang/core-entry/src/main/java/org/apache/directory/server/core/entry/DefaultServerAttribute.java
(original)
+++ directory/apacheds/branches/bigbang/core-entry/src/main/java/org/apache/directory/server/core/entry/DefaultServerAttribute.java
Sat Mar 15 05:33:20 2008
@@ -367,7 +367,7 @@
     {
         if ( attributeType == null )
         {
-            throw new IllegalArgumentException( getErrorMessage( attributeType ) );
+            throw new IllegalArgumentException( "The AttributeType parameter should not be
null" );
         }
 
         this.attributeType = attributeType;
@@ -413,7 +413,7 @@
     {
         if ( attributeType == null )
         {
-            throw new IllegalArgumentException( getErrorMessage( attributeType ) );
+            throw new IllegalArgumentException( "The AttributeType parameter should not be
null" );
         }
         
         setAttributeType( attributeType );
@@ -427,7 +427,7 @@
     {
         if ( attributeType == null ) 
         {
-            String message = getErrorMessage( attributeType );
+            String message = "The AttributeType parameter should not be null";
             LOG.error( message );
             throw new IllegalArgumentException( message );
         }
@@ -472,7 +472,7 @@
     {
         if ( attributeType == null )
         {
-            throw new IllegalArgumentException( getErrorMessage( attributeType ) );
+            throw new IllegalArgumentException( "The AttributeType parameter should not be
null" );
         }
         
         setAttributeType( attributeType );
@@ -497,7 +497,7 @@
     {
         if ( attributeType == null )
         {
-            throw new IllegalArgumentException( getErrorMessage( attributeType ) );
+            throw new IllegalArgumentException( "The AttributeType parameter should not be
null" );
         }
 
         setAttributeType( attributeType );
@@ -522,7 +522,7 @@
     {
         if ( attributeType == null )
         {
-            throw new IllegalArgumentException( getErrorMessage( attributeType ) );
+            throw new IllegalArgumentException( "The AttributeType parameter should not be
null" );
         }
 
         setAttributeType( attributeType );

Modified: directory/apacheds/branches/bigbang/core-entry/src/test/java/org/apache/directory/server/core/entry/ServerBinaryValueTest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/core-entry/src/test/java/org/apache/directory/server/core/entry/ServerBinaryValueTest.java?rev=637403&r1=637402&r2=637403&view=diff
==============================================================================
--- directory/apacheds/branches/bigbang/core-entry/src/test/java/org/apache/directory/server/core/entry/ServerBinaryValueTest.java
(original)
+++ directory/apacheds/branches/bigbang/core-entry/src/test/java/org/apache/directory/server/core/entry/ServerBinaryValueTest.java
Sat Mar 15 05:33:20 2008
@@ -60,9 +60,9 @@
  */
 public class ServerBinaryValueTest
 {
-    static private TestServerEntryUtils.S s;
-    static private TestServerEntryUtils.AT at;
-    static private TestServerEntryUtils.MR mr;
+    private TestServerEntryUtils.S s;
+    private TestServerEntryUtils.AT at;
+    private TestServerEntryUtils.MR mr;
     
     private static final byte[] BYTES1 = new byte[]{0x01, 0x02, 0x03, 0x04};
     private static final byte[] BYTES2 = new byte[]{(byte)0x81, (byte)0x82, (byte)0x83, (byte)0x84};

Modified: directory/apacheds/branches/bigbang/core-entry/src/test/java/org/apache/directory/server/core/entry/ServerStringValueTest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/core-entry/src/test/java/org/apache/directory/server/core/entry/ServerStringValueTest.java?rev=637403&r1=637402&r2=637403&view=diff
==============================================================================
--- directory/apacheds/branches/bigbang/core-entry/src/test/java/org/apache/directory/server/core/entry/ServerStringValueTest.java
(original)
+++ directory/apacheds/branches/bigbang/core-entry/src/test/java/org/apache/directory/server/core/entry/ServerStringValueTest.java
Sat Mar 15 05:33:20 2008
@@ -68,9 +68,9 @@
  */
 public class ServerStringValueTest
 {
-    static private TestServerEntryUtils.S s;
-    static private TestServerEntryUtils.AT at;
-    static private TestServerEntryUtils.MR mr;
+    private TestServerEntryUtils.S s;
+    private TestServerEntryUtils.AT at;
+    private TestServerEntryUtils.MR mr;
 
     
     /**

Modified: directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/codec/LdapResult.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/codec/LdapResult.java?rev=637403&r1=637402&r2=637403&view=diff
==============================================================================
--- directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/codec/LdapResult.java
(original)
+++ directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/codec/LdapResult.java
Sat Mar 15 05:33:20 2008
@@ -345,7 +345,7 @@
                 LdapURL referral = referralIterator.next();
 
                 // Ecode the current referral
-                Value.encode( buffer, referral.getBytes() );
+                Value.encode( buffer, referral.getBytesReference() );
             }
         }
 

Modified: directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/codec/extended/operations/GracefulDisconnect.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/codec/extended/operations/GracefulDisconnect.java?rev=637403&r1=637402&r2=637403&view=diff
==============================================================================
--- directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/codec/extended/operations/GracefulDisconnect.java
(original)
+++ directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/codec/extended/operations/GracefulDisconnect.java
Sat Mar 15 05:33:20 2008
@@ -187,7 +187,7 @@
             while ( replicatedContextIterator.hasNext() )
             {
                 LdapURL url = replicatedContextIterator.next();
-                Value.encode( bb, url.getBytes() );
+                Value.encode( bb, url.getBytesReference() );
             }
         }
 

Modified: directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/codec/util/LdapURL.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/codec/util/LdapURL.java?rev=637403&r1=637402&r2=637403&view=diff
==============================================================================
--- directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/codec/util/LdapURL.java
(original)
+++ directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/codec/util/LdapURL.java
Sat Mar 15 05:33:20 2008
@@ -1410,11 +1410,28 @@
     }
     
     /**
-     * @return the bytes representing this LdapURL
+     * @return a reference on the interned bytes representing this LdapURL
      */
-    public byte[] getBytes()
+    public byte[] getBytesReference()
     {
         return bytes;
+    }
+    
+    /**
+     * @return a copy of the bytes representing this LdapURL
+     */
+    public byte[] getBytesCopy()
+    {
+        if ( bytes != null )
+        {
+            byte[] copy = new byte[bytes.length];
+            System.arraycopy( bytes, 0, copy, 0, bytes.length );
+            return copy;
+        }
+        else
+        {
+            return null;
+        }
     }
     
     /**

Modified: directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/entry/Modification.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/entry/Modification.java?rev=637403&r1=637402&r2=637403&view=diff
==============================================================================
--- directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/entry/Modification.java
(original)
+++ directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/entry/Modification.java
Sat Mar 15 05:33:20 2008
@@ -19,8 +19,6 @@
  */
 package org.apache.directory.shared.ldap.entry;
 
-import java.io.Serializable;
-
 
 /**
  * An internal interface for a ModificationItem. The name has been
@@ -29,7 +27,7 @@
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  * @version $Rev$, $Date$
  */
-public interface Modification extends Cloneable, Serializable
+public interface Modification extends Cloneable
 {
     /**
      *  @return the operation

Modified: directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/entry/client/ClientBinaryValue.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/entry/client/ClientBinaryValue.java?rev=637403&r1=637402&r2=637403&view=diff
==============================================================================
--- directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/entry/client/ClientBinaryValue.java
(original)
+++ directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/entry/client/ClientBinaryValue.java
Sat Mar 15 05:33:20 2008
@@ -79,7 +79,7 @@
         }
         else
         {
-            wrapped = null;
+            this.wrapped = null;
         }
         
         normalized = false;
@@ -228,8 +228,10 @@
             return ByteArrayComparator.INSTANCE.compare( getNormalizedValue(), binaryValue.getNormalizedValue()
);
         }
         
-        throw new NotImplementedException( "I don't really know how to compare anything other
" +
-                "than ServerBinaryValues at this point in time." );
+        String message = "I don't really know how to compare anything other " +
+            "than ServerBinaryValues at this point in time."; 
+        LOG.error( message );
+        throw new NotImplementedException( message );
     }
 
 

Modified: directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/schema/RegexNormalizer.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/schema/RegexNormalizer.java?rev=637403&r1=637402&r2=637403&view=diff
==============================================================================
--- directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/schema/RegexNormalizer.java
(original)
+++ directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/schema/RegexNormalizer.java
Sat Mar 15 05:33:20 2008
@@ -47,20 +47,24 @@
      * @param regexes
      *            the set of regular expressions used to transform values
      */
-    public RegexNormalizer(Pattern[] regexes)
+    public RegexNormalizer( Pattern[] regexes )
     {
         if ( regexes != null )
         {
             this.regexes = new Pattern[ regexes.length ];
             System.arraycopy( regexes, 0, this.regexes, 0, regexes.length );
-        } else {
-            this.regexes = null;
-        }
-        matchers = new Matcher[regexes.length];
 
-        for ( int i = 0; i < regexes.length; i++ )
+            matchers = new Matcher[regexes.length];
+
+            for ( int i = 0; i < regexes.length; i++ )
+            {
+                matchers[i] = regexes[i].matcher( "" );
+            }
+        } 
+        else 
         {
-            matchers[i] = regexes[i].matcher( "" );
+            this.regexes = null;
+            matchers = new Matcher[0];
         }
     }
 

Modified: directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/util/StringTools.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/util/StringTools.java?rev=637403&r1=637402&r2=637403&view=diff
==============================================================================
--- directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/util/StringTools.java
(original)
+++ directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/util/StringTools.java
Sat Mar 15 05:33:20 2008
@@ -2004,7 +2004,7 @@
         }
         else
         {
-            byte c = bytes[index++];
+            byte c = bytes[index];
 
             if ( ( ( c | 0x7F ) != 0x7F ) || ( ALPHA[c] == false ) )
             {
@@ -2035,7 +2035,7 @@
         }
         else
         {
-            char c = chars[index++];
+            char c = chars[index];
 
             if ( ( c > 127 ) || ( ALPHA[c] == false ) )
             {
@@ -2073,7 +2073,7 @@
         }
         else
         {
-            char c = string.charAt( index++ );
+            char c = string.charAt( index );
 
             if ( ( c > 127 ) || ( ALPHA[c] == false ) )
             {
@@ -2111,7 +2111,7 @@
         }
         else
         {
-            char c = string.charAt( index++ );
+            char c = string.charAt( index );
 
             if ( ( c > 127 ) || ( ALPHA_LOWER_CASE[c] == false ) )
             {
@@ -2149,7 +2149,7 @@
         }
         else
         {
-            char c = string.charAt( index++ );
+            char c = string.charAt( index );
 
             if ( ( c > 127 ) || ( ALPHA_UPPER_CASE[c] == false ) )
             {
@@ -2278,7 +2278,7 @@
         }
         else
         {
-            char c = string.charAt( index++ );
+            char c = string.charAt( index );
 
             if ( ( c > 127 ) || ( ALPHA_DIGIT[c] == false ) )
             {
@@ -2308,7 +2308,7 @@
         }
         else
         {
-            byte c = bytes[index++];
+            byte c = bytes[index];
 
             if ( ( ( c | 0x7F ) != 0x7F ) || ( CHAR[c] == false ) )
             {
@@ -2338,7 +2338,7 @@
         }
         else
         {
-            char c = chars[index++];
+            char c = chars[index];
 
             if ( ( c > 127 ) || ( CHAR[c] == false ) )
             {
@@ -2375,7 +2375,7 @@
         }
         else
         {
-            char c = string.charAt( index++ );
+            char c = string.charAt( index );
 
             if ( ( c > 127 ) || ( CHAR[c] == false ) )
             {
@@ -3246,9 +3246,7 @@
         StringBuffer sb = new StringBuffer();
         boolean isFirst = true;
 
-        Iterator<?> iter = map.keySet().iterator();
-
-        while ( iter.hasNext() )
+        for ( Map.Entry<?, ?> entry:map.entrySet() )
         {
             if ( isFirst )
             {
@@ -3259,9 +3257,8 @@
                 sb.append( ", " );
             }
 
-            Object key = iter.next();
-            sb.append( key );
-            sb.append( " = '" ).append( map.get( key ) ).append( "'" );
+            sb.append( entry.getKey() );
+            sb.append( " = '" ).append( entry.getValue() ).append( "'" );
         }
 
         return sb.toString();
@@ -3285,16 +3282,12 @@
 
         StringBuffer sb = new StringBuffer();
 
-        Iterator<?> iter = map.keySet().iterator();
-
-        while ( iter.hasNext() )
+        for ( Map.Entry<?, ?> entry:map.entrySet() )
         {
-            Object key = iter.next();
             sb.append( tabs );
-            sb.append( key );
-            Object value = map.get( key );
+            sb.append( entry.getKey() );
 
-            sb.append( " = '" ).append( value.toString() ).append( "'\n" );
+            sb.append( " = '" ).append( entry.getValue().toString() ).append( "'\n" );
         }
 
         return sb.toString();



Mime
View raw message