Author: ggregory
Date: Fri Aug 31 13:01:25 2012
New Revision: 1379436

URL: http://svn.apache.org/viewvc?rev=1379436&view=rev
Log:
Types casts fix two FindBugs report of RV_ABSOLUTE_VALUE_OF_RANDOM_INT.

Modified:
    
commons/proper/codec/trunk/src/main/java/org/apache/commons/codec/digest/UnixCrypt.java

Modified: 
commons/proper/codec/trunk/src/main/java/org/apache/commons/codec/digest/UnixCrypt.java
URL: 
http://svn.apache.org/viewvc/commons/proper/codec/trunk/src/main/java/org/apache/commons/codec/digest/UnixCrypt.java?rev=1379436&r1=1379435&r2=1379436&view=diff
==============================================================================
--- 
commons/proper/codec/trunk/src/main/java/org/apache/commons/codec/digest/UnixCrypt.java
 (original)
+++ 
commons/proper/codec/trunk/src/main/java/org/apache/commons/codec/digest/UnixCrypt.java
 Fri Aug 31 13:01:25 2012
@@ -238,8 +238,9 @@ public class UnixCrypt {
         if (salt == null) {
             Random randomGenerator = new Random();
             int numSaltChars = SALT_CHARS.length;
-            salt = "" + SALT_CHARS[Math.abs(randomGenerator.nextInt()) % 
numSaltChars] +
-                   SALT_CHARS[Math.abs(randomGenerator.nextInt()) % 
numSaltChars];
+            // Types casts fix two FindBugs report of 
RV_ABSOLUTE_VALUE_OF_RANDOM_INT.
+            salt = "" + 
SALT_CHARS[(int)Math.abs((long)randomGenerator.nextInt()) % numSaltChars] +
+                   SALT_CHARS[(int)Math.abs((long)randomGenerator.nextInt()) % 
numSaltChars];
         } else if (!salt.matches("^[" + B64.B64T + "]{2,}$")) {
             throw new IllegalArgumentException("Invalid salt value: " + salt);
         }


Reply via email to