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 2013/03/29 16:48:57 UTC

svn commit: r1462504 - /commons/proper/math/trunk/src/main/java/org/apache/commons/math3/util/ResizableDoubleArray.java

Author: luc
Date: Fri Mar 29 15:48:57 2013
New Revision: 1462504

URL: http://svn.apache.org/r1462504
Log:
Fixed findbugs warning.

Modified:
    commons/proper/math/trunk/src/main/java/org/apache/commons/math3/util/ResizableDoubleArray.java

Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math3/util/ResizableDoubleArray.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math3/util/ResizableDoubleArray.java?rev=1462504&r1=1462503&r2=1462504&view=diff
==============================================================================
--- commons/proper/math/trunk/src/main/java/org/apache/commons/math3/util/ResizableDoubleArray.java (original)
+++ commons/proper/math/trunk/src/main/java/org/apache/commons/math3/util/ResizableDoubleArray.java Fri Mar 29 15:48:57 2013
@@ -934,7 +934,15 @@ public class ResizableDoubleArray implem
      * @since 3.1
      */
     public double compute(MathArrays.Function f) {
-        return f.evaluate(internalArray, startIndex, numElements);
+        final double[] array;
+        final int start;
+        final int num;
+        synchronized(this) {
+            array = internalArray;
+            start = startIndex;
+            num   = numElements;
+        }
+        return f.evaluate(array, start, num);
     }
 
     /**



Re: [Math] Re: svn commit: r1462504 - /commons/proper/math/trunk/src/main/java/org/apache/commons/math3/util/ResizableDoubleArray.java

Posted by Luc Maisonobe <Lu...@free.fr>.
Le 29/03/2013 17:37, Gilles a écrit :
> On Fri, 29 Mar 2013 15:48:57 -0000, luc@apache.org wrote:
>> Author: luc
>> Date: Fri Mar 29 15:48:57 2013
>> New Revision: 1462504
>>
>> URL: http://svn.apache.org/r1462504
>> Log:
>> Fixed findbugs warning.

Hi Gilles,

> 
> This one should stay.
> We agreed that "ResizableDoubleArray" should not be synchronized at the
> CM level.
> Instead of adding "synchronized" keywords, it is rather all the others
> that must
> be removed (but we decided no to do it before 4.0 in order to not break
> user code
> that potentially rely on the existing, but broken, synchronization).

We can still remove all the synchronize (including this one) for 4.0.
I don't think the fix does any harm.

Luc

> 
> Best regards,
> Gilles
> 
>>
>> Modified:
>>
>>
>> commons/proper/math/trunk/src/main/java/org/apache/commons/math3/util/ResizableDoubleArray.java
>>
>>
>> Modified:
>>
>> commons/proper/math/trunk/src/main/java/org/apache/commons/math3/util/ResizableDoubleArray.java
>>
>> URL:
>>
>> http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math3/util/ResizableDoubleArray.java?rev=1462504&r1=1462503&r2=1462504&view=diff
>>
>>
>> ==============================================================================
>>
>> ---
>>
>> commons/proper/math/trunk/src/main/java/org/apache/commons/math3/util/ResizableDoubleArray.java
>>
>> (original)
>> +++
>>
>> commons/proper/math/trunk/src/main/java/org/apache/commons/math3/util/ResizableDoubleArray.java
>>
>> Fri Mar 29 15:48:57 2013
>> @@ -934,7 +934,15 @@ public class ResizableDoubleArray implem
>>       * @since 3.1
>>       */
>>      public double compute(MathArrays.Function f) {
>> -        return f.evaluate(internalArray, startIndex, numElements);
>> +        final double[] array;
>> +        final int start;
>> +        final int num;
>> +        synchronized(this) {
>> +            array = internalArray;
>> +            start = startIndex;
>> +            num   = numElements;
>> +        }
>> +        return f.evaluate(array, start, num);
>>      }
>>
>>      /**
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
> For additional commands, e-mail: dev-help@commons.apache.org
> 
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
For additional commands, e-mail: dev-help@commons.apache.org


[Math] Re: svn commit: r1462504 - /commons/proper/math/trunk/src/main/java/org/apache/commons/math3/util/ResizableDoubleArray.java

Posted by Gilles <gi...@harfang.homelinux.org>.
On Fri, 29 Mar 2013 15:48:57 -0000, luc@apache.org wrote:
> Author: luc
> Date: Fri Mar 29 15:48:57 2013
> New Revision: 1462504
>
> URL: http://svn.apache.org/r1462504
> Log:
> Fixed findbugs warning.

This one should stay.
We agreed that "ResizableDoubleArray" should not be synchronized at the 
CM level.
Instead of adding "synchronized" keywords, it is rather all the others 
that must
be removed (but we decided no to do it before 4.0 in order to not break 
user code
that potentially rely on the existing, but broken, synchronization).

Best regards,
Gilles

>
> Modified:
>
> 
> commons/proper/math/trunk/src/main/java/org/apache/commons/math3/util/ResizableDoubleArray.java
>
> Modified:
> 
> commons/proper/math/trunk/src/main/java/org/apache/commons/math3/util/ResizableDoubleArray.java
> URL:
> 
> http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math3/util/ResizableDoubleArray.java?rev=1462504&r1=1462503&r2=1462504&view=diff
> 
> ==============================================================================
> ---
> 
> commons/proper/math/trunk/src/main/java/org/apache/commons/math3/util/ResizableDoubleArray.java
> (original)
> +++
> 
> commons/proper/math/trunk/src/main/java/org/apache/commons/math3/util/ResizableDoubleArray.java
> Fri Mar 29 15:48:57 2013
> @@ -934,7 +934,15 @@ public class ResizableDoubleArray implem
>       * @since 3.1
>       */
>      public double compute(MathArrays.Function f) {
> -        return f.evaluate(internalArray, startIndex, numElements);
> +        final double[] array;
> +        final int start;
> +        final int num;
> +        synchronized(this) {
> +            array = internalArray;
> +            start = startIndex;
> +            num   = numElements;
> +        }
> +        return f.evaluate(array, start, num);
>      }
>
>      /**


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
For additional commands, e-mail: dev-help@commons.apache.org