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/11/03 13:19:50 UTC

[3/3] [math] Fixed inconsistent synchronization.

Fixed inconsistent synchronization.

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

Branch: refs/heads/MATH_3_X
Commit: f0c6d3c0c564b82f4e02f183ce7409332155ac36
Parents: be8563a
Author: Luc Maisonobe <lu...@apache.org>
Authored: Tue Nov 3 12:22:46 2015 +0100
Committer: Luc Maisonobe <lu...@apache.org>
Committed: Tue Nov 3 12:34:07 2015 +0100

----------------------------------------------------------------------
 .../math3/util/ResizableDoubleArray.java        | 20 ++++++++++++--------
 1 file changed, 12 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/commons-math/blob/f0c6d3c0/src/main/java/org/apache/commons/math3/util/ResizableDoubleArray.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/math3/util/ResizableDoubleArray.java b/src/main/java/org/apache/commons/math3/util/ResizableDoubleArray.java
index d49f6a8..89c42da 100644
--- a/src/main/java/org/apache/commons/math3/util/ResizableDoubleArray.java
+++ b/src/main/java/org/apache/commons/math3/util/ResizableDoubleArray.java
@@ -808,13 +808,15 @@ public class ResizableDoubleArray implements DoubleArray, Serializable {
      */
     @Deprecated
     public int getExpansionMode() {
-        switch (expansionMode) {
-        case MULTIPLICATIVE:
-            return MULTIPLICATIVE_MODE;
-        case ADDITIVE:
-            return ADDITIVE_MODE;
-        default:
-            throw new MathInternalError(); // Should never happen.
+        synchronized (this) {
+            switch (expansionMode) {
+                case MULTIPLICATIVE:
+                    return MULTIPLICATIVE_MODE;
+                case ADDITIVE:
+                    return ADDITIVE_MODE;
+                default:
+                    throw new MathInternalError(); // Should never happen.
+            }
         }
     }
 
@@ -1026,7 +1028,9 @@ public class ResizableDoubleArray implements DoubleArray, Serializable {
      */
     @Deprecated
     public void setExpansionMode(ExpansionMode expansionMode) {
-        this.expansionMode = expansionMode;
+        synchronized(this) {
+            this.expansionMode = expansionMode;
+        }
     }
 
     /**