commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From l..@apache.org
Subject [3/3] [math] Fixed inconsistent synchronization.
Date Tue, 03 Nov 2015 12:19:50 GMT
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 <luc@apache.org>
Authored: Tue Nov 3 12:22:46 2015 +0100
Committer: Luc Maisonobe <luc@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;
+        }
     }
 
     /**


Mime
View raw message