Repository: commons-math
Updated Branches:
  refs/heads/master 03326f611 -> 487ac1980


[MATH-1294] Fix potential race condition in PolynomialUtils. Thanks to Kamil 
Włodarczyk


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

Branch: refs/heads/master
Commit: 487ac1980148522d628e1d2aab50b107c372798b
Parents: 03326f6
Author: Thomas Neidhart <thomas.neidh...@gmail.com>
Authored: Mon Nov 23 23:13:10 2015 +0100
Committer: Thomas Neidhart <thomas.neidh...@gmail.com>
Committed: Mon Nov 23 23:13:10 2015 +0100

----------------------------------------------------------------------
 src/changes/changes.xml                                         | 5 +++++
 .../commons/math4/analysis/polynomials/PolynomialsUtils.java    | 4 ++--
 2 files changed, 7 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/commons-math/blob/487ac198/src/changes/changes.xml
----------------------------------------------------------------------
diff --git a/src/changes/changes.xml b/src/changes/changes.xml
index 74341f0..fc75ddc 100644
--- a/src/changes/changes.xml
+++ b/src/changes/changes.xml
@@ -54,6 +54,11 @@ If the output is not quite correct, check for invisible 
trailing spaces!
     </release>
 
     <release version="4.0" date="XXXX-XX-XX" description="">
+      <action dev="tn" type="fix" issue="MATH-1294" due-to="Kamil 
Włodarczyk"> <!-- backported to 3.6 -->
+        Fixed potential race condition in PolynomialUtils#buildPolynomial in
+        case polynomials are generated from multiple threads. Furthermore, the
+        synchronization is now performed on the coefficient list instead of 
the class.
+      </action>
       <action dev="psteitz" type="update" issue="MATH-1246">
         Added bootstrap method to 2-sample KolmogorovSmirnovTest.
       </action>

http://git-wip-us.apache.org/repos/asf/commons-math/blob/487ac198/src/main/java/org/apache/commons/math4/analysis/polynomials/PolynomialsUtils.java
----------------------------------------------------------------------
diff --git 
a/src/main/java/org/apache/commons/math4/analysis/polynomials/PolynomialsUtils.java
 
b/src/main/java/org/apache/commons/math4/analysis/polynomials/PolynomialsUtils.java
index 8574b86..346644e 100644
--- 
a/src/main/java/org/apache/commons/math4/analysis/polynomials/PolynomialsUtils.java
+++ 
b/src/main/java/org/apache/commons/math4/analysis/polynomials/PolynomialsUtils.java
@@ -365,8 +365,8 @@ public class PolynomialsUtils {
                                                       final List<BigFraction> 
coefficients,
                                                       final 
RecurrenceCoefficientsGenerator generator) {
 
-        final int maxDegree = (int) FastMath.floor(FastMath.sqrt(2 * 
coefficients.size())) - 1;
-        synchronized (PolynomialsUtils.class) {
+        synchronized (coefficients) {
+            final int maxDegree = (int) FastMath.floor(FastMath.sqrt(2 * 
coefficients.size())) - 1;
             if (degree > maxDegree) {
                 computeUpToDegree(degree, maxDegree, generator, coefficients);
             }

Reply via email to