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

This commit is contained in:
Thomas Neidhart 2015-11-23 23:13:10 +01:00
parent 03326f6116
commit 487ac19801
2 changed files with 7 additions and 2 deletions

View File

@ -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>

View File

@ -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);
}