You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by lu...@apache.org on 2015/05/07 16:46:34 UTC

[1/2] [math] Fixed equals/hashcode contract failure for Dfp.

Repository: commons-math
Updated Branches:
  refs/heads/MATH_3_X 9e1b0acab -> cf462bc5d


Fixed equals/hashcode contract failure for Dfp.

JIRA: MATH-1118

Thanks to Cyrille Artho.

Project: http://git-wip-us.apache.org/repos/asf/commons-math/repo
Commit: http://git-wip-us.apache.org/repos/asf/commons-math/commit/12a69814
Tree: http://git-wip-us.apache.org/repos/asf/commons-math/tree/12a69814
Diff: http://git-wip-us.apache.org/repos/asf/commons-math/diff/12a69814

Branch: refs/heads/MATH_3_X
Commit: 12a69814b0195caa90628a8ffa70cb887fbcc00d
Parents: 9e1b0ac
Author: Luc Maisonobe <lu...@apache.org>
Authored: Thu May 7 16:33:19 2015 +0200
Committer: Luc Maisonobe <lu...@apache.org>
Committed: Thu May 7 16:33:19 2015 +0200

----------------------------------------------------------------------
 src/changes/changes.xml                                 |  3 +++
 src/main/java/org/apache/commons/math3/dfp/Dfp.java     |  2 +-
 src/test/java/org/apache/commons/math3/dfp/DfpTest.java | 10 ++++++++++
 3 files changed, 14 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/commons-math/blob/12a69814/src/changes/changes.xml
----------------------------------------------------------------------
diff --git a/src/changes/changes.xml b/src/changes/changes.xml
index 4501eee..f8749e8 100644
--- a/src/changes/changes.xml
+++ b/src/changes/changes.xml
@@ -51,6 +51,9 @@ If the output is not quite correct, check for invisible trailing spaces!
   </properties>
   <body>
     <release version="3.6" date="XXXX-XX-XX" description="">
+      <action dev="luc" type="fix" issue="MATH-1218" >
+        Fixed equals/hashcode contract failure for Dfp.
+      </action>
       <action dev="luc" type="fix" issue="MATH-1223" >
        Fixed wrong splitting of huge number in extended accuracy algorithms.
       </action>

http://git-wip-us.apache.org/repos/asf/commons-math/blob/12a69814/src/main/java/org/apache/commons/math3/dfp/Dfp.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/math3/dfp/Dfp.java b/src/main/java/org/apache/commons/math3/dfp/Dfp.java
index 19d79a8..bc1545b 100644
--- a/src/main/java/org/apache/commons/math3/dfp/Dfp.java
+++ b/src/main/java/org/apache/commons/math3/dfp/Dfp.java
@@ -922,7 +922,7 @@ public class Dfp implements RealFieldElement<Dfp> {
      */
     @Override
     public int hashCode() {
-        return 17 + (sign << 8) + (nans << 16) + exp + Arrays.hashCode(mant);
+        return 17 + (isZero() ? 0 : (sign << 8)) + (nans << 16) + exp + Arrays.hashCode(mant);
     }
 
     /** Check if instance is not equal to x.

http://git-wip-us.apache.org/repos/asf/commons-math/blob/12a69814/src/test/java/org/apache/commons/math3/dfp/DfpTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/math3/dfp/DfpTest.java b/src/test/java/org/apache/commons/math3/dfp/DfpTest.java
index 236dd79..49bee1a 100644
--- a/src/test/java/org/apache/commons/math3/dfp/DfpTest.java
+++ b/src/test/java/org/apache/commons/math3/dfp/DfpTest.java
@@ -1650,4 +1650,14 @@ public class DfpTest extends ExtendedFieldElementAbstractTest<Dfp> {
         Assert.assertTrue(field.newDfp("NaN").isNaN());
     }
 
+    @Test
+    public void testEqualsHashcodeContract() {
+        DfpField var1 = new DfpField(1);
+        Dfp var6 = var1.newDfp(-0.0d);
+        Dfp var5 = var1.newDfp(0L);
+
+        // Checks the contract:  equals-hashcode on var5 and var6
+        Assert.assertTrue(var5.equals(var6) ? var5.hashCode() == var6.hashCode() : true);
+    }
+
 }


[2/2] [math] Updated build system (checkstyl and pom).

Posted by lu...@apache.org.
Updated build system (checkstyl and pom).

Project: http://git-wip-us.apache.org/repos/asf/commons-math/repo
Commit: http://git-wip-us.apache.org/repos/asf/commons-math/commit/cf462bc5
Tree: http://git-wip-us.apache.org/repos/asf/commons-math/tree/cf462bc5
Diff: http://git-wip-us.apache.org/repos/asf/commons-math/diff/cf462bc5

Branch: refs/heads/MATH_3_X
Commit: cf462bc5d5a90f473290e7a502a5e5b3934531a5
Parents: 12a6981
Author: Luc Maisonobe <lu...@apache.org>
Authored: Thu May 7 16:44:17 2015 +0200
Committer: Luc Maisonobe <lu...@apache.org>
Committed: Thu May 7 16:44:17 2015 +0200

----------------------------------------------------------------------
 checkstyle.xml |  9 +--------
 pom.xml        | 10 +++++-----
 2 files changed, 6 insertions(+), 13 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/commons-math/blob/cf462bc5/checkstyle.xml
----------------------------------------------------------------------
diff --git a/checkstyle.xml b/checkstyle.xml
index 5549177..444f84f 100644
--- a/checkstyle.xml
+++ b/checkstyle.xml
@@ -25,8 +25,6 @@
 
   <module name="TreeWalker">
 
-    <property name="cacheFile" value="target/checkstyle-cachefile"/>
-
     <!-- Operator must be at end of wrapped line -->
     <module name="OperatorWrap">
       <property name="option" value="eol"/>
@@ -45,14 +43,9 @@
     <module name="JavadocMethod">
       <property name="allowUndeclaredRTE" value="true"/>
       <property name="allowThrowsTagsForSubclasses" value="true"/>
+      <property name="validateThrows" value="false"/>
     </module>
 
-   <!-- Allow declaration of detailed exception set -->
-   <module name="RedundantThrows">
-     <property name="allowUnchecked"  value="true"/>
-     <property name="allowSubclasses" value="true"/>
-   </module>
-        
     <!-- Require field javadoc -->
     <module name="JavadocVariable"/>
         

http://git-wip-us.apache.org/repos/asf/commons-math/blob/cf462bc5/pom.xml
----------------------------------------------------------------------
diff --git a/pom.xml b/pom.xml
index 6820934..d270185 100644
--- a/pom.xml
+++ b/pom.xml
@@ -19,7 +19,7 @@
   <parent>
     <groupId>org.apache.commons</groupId>
     <artifactId>commons-parent</artifactId>
-    <version>34</version>
+    <version>37</version>
   </parent>
   <modelVersion>4.0.0</modelVersion>
   <groupId>org.apache.commons</groupId>
@@ -386,12 +386,12 @@
     <maven.compiler.source>1.5</maven.compiler.source>
     <maven.compiler.target>1.5</maven.compiler.target>
     <math.pmd.version>2.7.1</math.pmd.version>
-    <math.findbugs.version>2.5.1</math.findbugs.version>
-    <math.checkstyle.version>2.9.1</math.checkstyle.version>
+    <math.findbugs.version>3.0.1</math.findbugs.version>
+    <math.checkstyle.version>2.15</math.checkstyle.version>
     <math.clirr.version>2.6.1</math.clirr.version>
 
     <!-- Temporary fix to support Java 8 -->
-    <commons.jacoco.version>0.7.2.201409121644</commons.jacoco.version>
+    <commons.jacoco.version>0.7.4.201502262128</commons.jacoco.version>
     <commons.jacoco.classRatio>0.96</commons.jacoco.classRatio>
     <commons.jacoco.instructionRatio>0.8</commons.jacoco.instructionRatio>
     <commons.jacoco.methodRatio>0.8</commons.jacoco.methodRatio>
@@ -406,7 +406,7 @@
 
     <!-- Temporary fix to replace svn-based build number with git-based build number -->
     <buildnumber.skip>true</buildnumber.skip>
-    <math.jgit.buildnumber.version>1.2.8</math.jgit.buildnumber.version>
+    <math.jgit.buildnumber.version>1.2.10</math.jgit.buildnumber.version>
     <implementation.build>${git.revision}; ${maven.build.timestamp}</implementation.build>
 
   </properties>