directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r1728111 - /directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/api/ldap/model/ldif/anonymizer/IntegerAnonymizer.java
Date Tue, 02 Feb 2016 13:04:02 GMT
Author: elecharny
Date: Tue Feb  2 13:04:02 2016
New Revision: 1728111

URL: http://svn.apache.org/viewvc?rev=1728111&view=rev
Log:
Fixed the Integer anonymizer which was generating some wrong value randomly (integers longer
than 2 starting with '0')

Modified:
    directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/api/ldap/model/ldif/anonymizer/IntegerAnonymizer.java

Modified: directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/api/ldap/model/ldif/anonymizer/IntegerAnonymizer.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/api/ldap/model/ldif/anonymizer/IntegerAnonymizer.java?rev=1728111&r1=1728110&r2=1728111&view=diff
==============================================================================
--- directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/api/ldap/model/ldif/anonymizer/IntegerAnonymizer.java
(original)
+++ directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/api/ldap/model/ldif/anonymizer/IntegerAnonymizer.java
Tue Feb  2 13:04:02 2016
@@ -62,11 +62,22 @@ public class IntegerAnonymizer extends A
                 // Same size
                 char[] newValue = new char[length];
 
+                boolean isFirst = true;
+                
                 for ( int i = 0; i < length; i++ )
                 {
-                    newValue[i] = ( char ) ( random.nextInt( '9' - '0' ) + '0' );
-                }
+                    if ( isFirst && length > 1 ) 
+                    {
+                        newValue[i] = ( char ) ( random.nextInt( 9 ) + '1' );
+                    }
+                    else
+                    {
+                        newValue[i] = ( char ) ( random.nextInt( 10 ) + '0' );
+                    }
 
+                    isFirst = false;
+                }
+                
                 try
                 {
                     result.add( new String( newValue ) );



Mime
View raw message