You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by ce...@apache.org on 2012/06/25 07:22:59 UTC

svn commit: r1353386 - in /commons/proper/math/trunk/src/main/java/org/apache/commons/math3/util: Incrementor.java IterationManager.java

Author: celestin
Date: Mon Jun 25 05:22:58 2012
New Revision: 1353386

URL: http://svn.apache.org/viewvc?rev=1353386&view=rev
Log:
Reverted changes committed in r1353140. In o.a.c.m3.util.Incrementor, a NullPointerException is now thrown if the call-back function specified at construction is null. o.a.c.m3.util.IterationManager was updated accordingly (used to explicitely use the constructor with null argument).

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

Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math3/util/Incrementor.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math3/util/Incrementor.java?rev=1353386&r1=1353385&r2=1353386&view=diff
==============================================================================
--- commons/proper/math/trunk/src/main/java/org/apache/commons/math3/util/Incrementor.java (original)
+++ commons/proper/math/trunk/src/main/java/org/apache/commons/math3/util/Incrementor.java Mon Jun 25 05:22:58 2012
@@ -58,7 +58,13 @@ public class Incrementor {
      * @param max Maximal count.
      */
     public Incrementor(int max) {
-        this(max, null);
+        this(max,
+             new MaxCountExceededCallback() {
+                 /** {@inheritDoc} */
+                 public void trigger(int max) {
+                     throw new MaxCountExceededException(max);
+                 }
+             });
     }
 
     /**
@@ -66,22 +72,16 @@ public class Incrementor {
      * counter exhaustion.
      *
      * @param max Maximal count.
-     * @param cb Function to be called when the maximal count has been reached
-     * (can be {@code null}).
+     * @param cb Function to be called when the maximal count has been reached.
+     * @throws NullPointerException if {@code cb} is {@code null}
      */
     public Incrementor(int max,
                        MaxCountExceededCallback cb) {
-        maximalCount = max;
-        if (cb != null) {
-            maxCountCallback = cb;
-        } else {
-            maxCountCallback = new MaxCountExceededCallback() {
-                /** {@inheritDoc} */
-                public void trigger(int max) {
-                    throw new MaxCountExceededException(max);
-                }
-            };
+        if (cb == null){
+            throw new NullPointerException();
         }
+        maximalCount = max;
+        maxCountCallback = cb;
     }
 
     /**

Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math3/util/IterationManager.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math3/util/IterationManager.java?rev=1353386&r1=1353385&r2=1353386&view=diff
==============================================================================
--- commons/proper/math/trunk/src/main/java/org/apache/commons/math3/util/IterationManager.java (original)
+++ commons/proper/math/trunk/src/main/java/org/apache/commons/math3/util/IterationManager.java Mon Jun 25 05:22:58 2012
@@ -43,7 +43,8 @@ public class IterationManager {
      * @param maxIterations the maximum number of iterations
      */
     public IterationManager(final int maxIterations) {
-        this(maxIterations, null);
+        this.iterations = new Incrementor(maxIterations);
+        this.listeners = new CopyOnWriteArrayList<IterationListener>();
     }
 
     /**
@@ -51,10 +52,14 @@ public class IterationManager {
      *
      * @param maxIterations the maximum number of iterations
      * @param callBack the function to be called when the maximum number of
-     * iterations has been reached (can be {@code null})
+     * iterations has been reached
+     * @throws NullPointerException if {@code callBack} is {@code null}
      */
     public IterationManager(final int maxIterations,
                             final Incrementor.MaxCountExceededCallback callBack) {
+        if (callBack == null) {
+            throw new NullPointerException();
+        }
         this.iterations = new Incrementor(maxIterations, callBack);
         this.listeners = new CopyOnWriteArrayList<IterationListener>();
     }



Re: svn commit: r1353386 - in /commons/proper/math/trunk/src/main/java/org/apache/commons/math3/util: Incrementor.java IterationManager.java

Posted by Sébastien Brisard <se...@m4x.org>.
Hi,
can't believe I didn't spot that earlier... Should be OK now (at
last!!!) -- see r1353586.
Best regards,
Sébastien

2012/6/25 Gilles Sadowski <gi...@harfang.homelinux.org>:
> Hi.
>
>> 2012/6/25 Gilles Sadowski <gi...@harfang.homelinux.org>:
>> > Hello Sébastien.
>> >
>> >>      /**
>> >> @@ -66,22 +72,16 @@ public class Incrementor {
>> >>       * counter exhaustion.
>> >>       *
>> >>       * @param max Maximal count.
>> >> -     * @param cb Function to be called when the maximal count has been reached
>> >> -     * (can be {@code null}).
>> >> +     * @param cb Function to be called when the maximal count has been reached.
>> >> +     * @throws NullPointerException if {@code cb} is {@code null}
>> >                  ^^^^^^^^^^^^^^^^^^^^
>> >
>> >>       */
>> >>      public Incrementor(int max,
>> >>                         MaxCountExceededCallback cb) {
>> >> -        maximalCount = max;
>> >> -        if (cb != null) {
>> >> -            maxCountCallback = cb;
>> >> -        } else {
>> >> -            maxCountCallback = new MaxCountExceededCallback() {
>> >> -                /** {@inheritDoc} */
>> >> -                public void trigger(int max) {
>> >> -                    throw new MaxCountExceededException(max);
>> >> -                }
>> >> -            };
>> >> +        if (cb == null){
>> >> +            throw new NullPointerException();
>> >
>> > See comment in class "o.a.c.m.NullArgumentException".
>> >
>> I'm sorry, I totally missed that (and you did use the correct
>> exception in your previous post...).
>
> Thanks for the change.
>
>>
>> >>          }
>> >> +        maximalCount = max;
>> >> +        maxCountCallback = cb;
>> >>      }
>> >>
>> >>      /**
>> >>
>> >> Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math3/util/IterationManager.java
>> >> URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math3/util/IterationManager.java?rev=1353386&r1=1353385&r2=1353386&view=diff
>> >> ==============================================================================
>> >> --- commons/proper/math/trunk/src/main/java/org/apache/commons/math3/util/IterationManager.java (original)
>> >> +++ commons/proper/math/trunk/src/main/java/org/apache/commons/math3/util/IterationManager.java Mon Jun 25 05:22:58 2012
>> >> @@ -43,7 +43,8 @@ public class IterationManager {
>> >>       * @param maxIterations the maximum number of iterations
>> >>       */
>> >>      public IterationManager(final int maxIterations) {
>> >> -        this(maxIterations, null);
>> >> +        this.iterations = new Incrementor(maxIterations);
>> >> +        this.listeners = new CopyOnWriteArrayList<IterationListener>();
>> >>      }
>> >>
>> >>      /**
>> >> @@ -51,10 +52,14 @@ public class IterationManager {
>> >>       *
>> >>       * @param maxIterations the maximum number of iterations
>> >>       * @param callBack the function to be called when the maximum number of
>> >> -     * iterations has been reached (can be {@code null})
>> >> +     * iterations has been reached
>> >> +     * @throws NullPointerException if {@code callBack} is {@code null}
>> >                  ^^^^^^^^^^^^^^^^^^^^
>> >
>> >>       */
>> >>      public IterationManager(final int maxIterations,
>> >>                              final Incrementor.MaxCountExceededCallback callBack) {
>> >> +        if (callBack == null) {
>> >> +            throw new NullPointerException();
>> >
>> > Ditto.
>
> Sorry I didn't noticed before but I think that this check is redundant
> with ...
>
>> >
>> >> +        }
>> >>          this.iterations = new Incrementor(maxIterations, callBack);
>
> ... the one now performed at Incrementor's construction.
>
>> >>          this.listeners = new CopyOnWriteArrayList<IterationListener>();
>> >>      }
>> >>
>> >
>> > Best,
>> > Gilles
>> >
>> > ---------------------------------------------------------------------
>> > To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
>> > For additional commands, e-mail: dev-help@commons.apache.org
>> >
>>
>> Corrected in r1353451. Thanks again for reviewing this (and for your
>> patience...).
>
>
> Thanks,
> Gilles
>
> ---------------------------------------------------------------------
> 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


Re: svn commit: r1353386 - in /commons/proper/math/trunk/src/main/java/org/apache/commons/math3/util: Incrementor.java IterationManager.java

Posted by Gilles Sadowski <gi...@harfang.homelinux.org>.
Hi.

> 2012/6/25 Gilles Sadowski <gi...@harfang.homelinux.org>:
> > Hello Sébastien.
> >
> >>      /**
> >> @@ -66,22 +72,16 @@ public class Incrementor {
> >>       * counter exhaustion.
> >>       *
> >>       * @param max Maximal count.
> >> -     * @param cb Function to be called when the maximal count has been reached
> >> -     * (can be {@code null}).
> >> +     * @param cb Function to be called when the maximal count has been reached.
> >> +     * @throws NullPointerException if {@code cb} is {@code null}
> >                  ^^^^^^^^^^^^^^^^^^^^
> >
> >>       */
> >>      public Incrementor(int max,
> >>                         MaxCountExceededCallback cb) {
> >> -        maximalCount = max;
> >> -        if (cb != null) {
> >> -            maxCountCallback = cb;
> >> -        } else {
> >> -            maxCountCallback = new MaxCountExceededCallback() {
> >> -                /** {@inheritDoc} */
> >> -                public void trigger(int max) {
> >> -                    throw new MaxCountExceededException(max);
> >> -                }
> >> -            };
> >> +        if (cb == null){
> >> +            throw new NullPointerException();
> >
> > See comment in class "o.a.c.m.NullArgumentException".
> >
> I'm sorry, I totally missed that (and you did use the correct
> exception in your previous post...).

Thanks for the change.

> 
> >>          }
> >> +        maximalCount = max;
> >> +        maxCountCallback = cb;
> >>      }
> >>
> >>      /**
> >>
> >> Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math3/util/IterationManager.java
> >> URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math3/util/IterationManager.java?rev=1353386&r1=1353385&r2=1353386&view=diff
> >> ==============================================================================
> >> --- commons/proper/math/trunk/src/main/java/org/apache/commons/math3/util/IterationManager.java (original)
> >> +++ commons/proper/math/trunk/src/main/java/org/apache/commons/math3/util/IterationManager.java Mon Jun 25 05:22:58 2012
> >> @@ -43,7 +43,8 @@ public class IterationManager {
> >>       * @param maxIterations the maximum number of iterations
> >>       */
> >>      public IterationManager(final int maxIterations) {
> >> -        this(maxIterations, null);
> >> +        this.iterations = new Incrementor(maxIterations);
> >> +        this.listeners = new CopyOnWriteArrayList<IterationListener>();
> >>      }
> >>
> >>      /**
> >> @@ -51,10 +52,14 @@ public class IterationManager {
> >>       *
> >>       * @param maxIterations the maximum number of iterations
> >>       * @param callBack the function to be called when the maximum number of
> >> -     * iterations has been reached (can be {@code null})
> >> +     * iterations has been reached
> >> +     * @throws NullPointerException if {@code callBack} is {@code null}
> >                  ^^^^^^^^^^^^^^^^^^^^
> >
> >>       */
> >>      public IterationManager(final int maxIterations,
> >>                              final Incrementor.MaxCountExceededCallback callBack) {
> >> +        if (callBack == null) {
> >> +            throw new NullPointerException();
> >
> > Ditto.

Sorry I didn't noticed before but I think that this check is redundant
with ...

> >
> >> +        }
> >>          this.iterations = new Incrementor(maxIterations, callBack);

... the one now performed at Incrementor's construction.

> >>          this.listeners = new CopyOnWriteArrayList<IterationListener>();
> >>      }
> >>
> >
> > Best,
> > Gilles
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
> > For additional commands, e-mail: dev-help@commons.apache.org
> >
> 
> Corrected in r1353451. Thanks again for reviewing this (and for your
> patience...).


Thanks,
Gilles

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


Re: svn commit: r1353386 - in /commons/proper/math/trunk/src/main/java/org/apache/commons/math3/util: Incrementor.java IterationManager.java

Posted by Sébastien Brisard <se...@m4x.org>.
Hello Gilles,

2012/6/25 Gilles Sadowski <gi...@harfang.homelinux.org>:
> Hello Sébastien.
>
>>      /**
>> @@ -66,22 +72,16 @@ public class Incrementor {
>>       * counter exhaustion.
>>       *
>>       * @param max Maximal count.
>> -     * @param cb Function to be called when the maximal count has been reached
>> -     * (can be {@code null}).
>> +     * @param cb Function to be called when the maximal count has been reached.
>> +     * @throws NullPointerException if {@code cb} is {@code null}
>                  ^^^^^^^^^^^^^^^^^^^^
>
>>       */
>>      public Incrementor(int max,
>>                         MaxCountExceededCallback cb) {
>> -        maximalCount = max;
>> -        if (cb != null) {
>> -            maxCountCallback = cb;
>> -        } else {
>> -            maxCountCallback = new MaxCountExceededCallback() {
>> -                /** {@inheritDoc} */
>> -                public void trigger(int max) {
>> -                    throw new MaxCountExceededException(max);
>> -                }
>> -            };
>> +        if (cb == null){
>> +            throw new NullPointerException();
>
> See comment in class "o.a.c.m.NullArgumentException".
>
I'm sorry, I totally missed that (and you did use the correct
exception in your previous post...).

>>          }
>> +        maximalCount = max;
>> +        maxCountCallback = cb;
>>      }
>>
>>      /**
>>
>> Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math3/util/IterationManager.java
>> URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math3/util/IterationManager.java?rev=1353386&r1=1353385&r2=1353386&view=diff
>> ==============================================================================
>> --- commons/proper/math/trunk/src/main/java/org/apache/commons/math3/util/IterationManager.java (original)
>> +++ commons/proper/math/trunk/src/main/java/org/apache/commons/math3/util/IterationManager.java Mon Jun 25 05:22:58 2012
>> @@ -43,7 +43,8 @@ public class IterationManager {
>>       * @param maxIterations the maximum number of iterations
>>       */
>>      public IterationManager(final int maxIterations) {
>> -        this(maxIterations, null);
>> +        this.iterations = new Incrementor(maxIterations);
>> +        this.listeners = new CopyOnWriteArrayList<IterationListener>();
>>      }
>>
>>      /**
>> @@ -51,10 +52,14 @@ public class IterationManager {
>>       *
>>       * @param maxIterations the maximum number of iterations
>>       * @param callBack the function to be called when the maximum number of
>> -     * iterations has been reached (can be {@code null})
>> +     * iterations has been reached
>> +     * @throws NullPointerException if {@code callBack} is {@code null}
>                  ^^^^^^^^^^^^^^^^^^^^
>
>>       */
>>      public IterationManager(final int maxIterations,
>>                              final Incrementor.MaxCountExceededCallback callBack) {
>> +        if (callBack == null) {
>> +            throw new NullPointerException();
>
> Ditto.
>
>> +        }
>>          this.iterations = new Incrementor(maxIterations, callBack);
>>          this.listeners = new CopyOnWriteArrayList<IterationListener>();
>>      }
>>
>
> Best,
> Gilles
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
> For additional commands, e-mail: dev-help@commons.apache.org
>

Corrected in r1353451. Thanks again for reviewing this (and for your
patience...).
Sébastien


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


Re: svn commit: r1353386 - in /commons/proper/math/trunk/src/main/java/org/apache/commons/math3/util: Incrementor.java IterationManager.java

Posted by Gilles Sadowski <gi...@harfang.homelinux.org>.
Hello Sébastien.

>      /**
> @@ -66,22 +72,16 @@ public class Incrementor {
>       * counter exhaustion.
>       *
>       * @param max Maximal count.
> -     * @param cb Function to be called when the maximal count has been reached
> -     * (can be {@code null}).
> +     * @param cb Function to be called when the maximal count has been reached.
> +     * @throws NullPointerException if {@code cb} is {@code null}
                  ^^^^^^^^^^^^^^^^^^^^

>       */
>      public Incrementor(int max,
>                         MaxCountExceededCallback cb) {
> -        maximalCount = max;
> -        if (cb != null) {
> -            maxCountCallback = cb;
> -        } else {
> -            maxCountCallback = new MaxCountExceededCallback() {
> -                /** {@inheritDoc} */
> -                public void trigger(int max) {
> -                    throw new MaxCountExceededException(max);
> -                }
> -            };
> +        if (cb == null){
> +            throw new NullPointerException();

See comment in class "o.a.c.m.NullArgumentException".

>          }
> +        maximalCount = max;
> +        maxCountCallback = cb;
>      }
>  
>      /**
> 
> Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math3/util/IterationManager.java
> URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math3/util/IterationManager.java?rev=1353386&r1=1353385&r2=1353386&view=diff
> ==============================================================================
> --- commons/proper/math/trunk/src/main/java/org/apache/commons/math3/util/IterationManager.java (original)
> +++ commons/proper/math/trunk/src/main/java/org/apache/commons/math3/util/IterationManager.java Mon Jun 25 05:22:58 2012
> @@ -43,7 +43,8 @@ public class IterationManager {
>       * @param maxIterations the maximum number of iterations
>       */
>      public IterationManager(final int maxIterations) {
> -        this(maxIterations, null);
> +        this.iterations = new Incrementor(maxIterations);
> +        this.listeners = new CopyOnWriteArrayList<IterationListener>();
>      }
>  
>      /**
> @@ -51,10 +52,14 @@ public class IterationManager {
>       *
>       * @param maxIterations the maximum number of iterations
>       * @param callBack the function to be called when the maximum number of
> -     * iterations has been reached (can be {@code null})
> +     * iterations has been reached
> +     * @throws NullPointerException if {@code callBack} is {@code null}
                  ^^^^^^^^^^^^^^^^^^^^

>       */
>      public IterationManager(final int maxIterations,
>                              final Incrementor.MaxCountExceededCallback callBack) {
> +        if (callBack == null) {
> +            throw new NullPointerException();

Ditto.

> +        }
>          this.iterations = new Incrementor(maxIterations, callBack);
>          this.listeners = new CopyOnWriteArrayList<IterationListener>();
>      }
> 

Best,
Gilles

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