Author: ggregory
Date: Sat Sep 1 16:49:52 2012
New Revision: 1379806
URL: http://svn.apache.org/viewvc?rev=1379806&view=rev
Log:
[CODEC-150] Remove unnecessary call to Math.abs().
Modified:
commons/proper/codec/trunk/src/changes/changes.xml
commons/proper/codec/trunk/src/main/java/org/apache/commons/codec/digest/UnixCrypt.java
Modified: commons/proper/codec/trunk/src/changes/changes.xml
URL:
http://svn.apache.org/viewvc/commons/proper/codec/trunk/src/changes/changes.xml?rev=1379806&r1=1379805&r2=1379806&view=diff
==============================================================================
--- commons/proper/codec/trunk/src/changes/changes.xml (original)
+++ commons/proper/codec/trunk/src/changes/changes.xml Sat Sep 1 16:49:52 2012
@@ -51,6 +51,9 @@ The <action> type attribute can be add,u
</release>
-->
<release version="1.7" date="TBD" description="Feature and fix release.">
+ <action issue="CODEC-150" dev="ggregory" type="add" due-to="lathspell">
+ Remove unnecessary call to Math.abs().
+ </action>
<action issue="CODEC-151" dev="ggregory" type="add" due-to="lathspell">
Remove unnecessary attempt to fill up the salt variable in UnixCrypt.
</action>
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=1379806&r1=1379805&r2=1379806&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
Sat Sep 1 16:49:52 2012
@@ -239,8 +239,8 @@ public class UnixCrypt {
Random randomGenerator = new Random();
int numSaltChars = SALT_CHARS.length;
// 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];
+ salt = "" + SALT_CHARS[randomGenerator.nextInt(numSaltChars)] +
+ SALT_CHARS[randomGenerator.nextInt(numSaltChars)];
} else if (!salt.matches("^[" + B64.B64T + "]{2,}$")) {
throw new IllegalArgumentException("Invalid salt value: " + salt);
}