You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by ki...@apache.org on 2012/07/19 17:23:19 UTC

svn commit: r1363382 - in /commons/proper/functor/trunk/src: main/java/org/apache/commons/functor/core/composite/UnarySequence.java test/java/org/apache/commons/functor/core/composite/TestUnarySequence.java

Author: kinow
Date: Thu Jul 19 15:23:19 2012
New Revision: 1363382

URL: http://svn.apache.org/viewvc?rev=1363382&view=rev
Log:
FIXED FUNCTOR-21: Added an extra verification in the then() method of UnarySequence to avoid the NPE. Tests in place.

Modified:
    commons/proper/functor/trunk/src/main/java/org/apache/commons/functor/core/composite/UnarySequence.java
    commons/proper/functor/trunk/src/test/java/org/apache/commons/functor/core/composite/TestUnarySequence.java

Modified: commons/proper/functor/trunk/src/main/java/org/apache/commons/functor/core/composite/UnarySequence.java
URL: http://svn.apache.org/viewvc/commons/proper/functor/trunk/src/main/java/org/apache/commons/functor/core/composite/UnarySequence.java?rev=1363382&r1=1363381&r2=1363382&view=diff
==============================================================================
--- commons/proper/functor/trunk/src/main/java/org/apache/commons/functor/core/composite/UnarySequence.java (original)
+++ commons/proper/functor/trunk/src/main/java/org/apache/commons/functor/core/composite/UnarySequence.java Thu Jul 19 15:23:19 2012
@@ -98,7 +98,9 @@ public class UnarySequence<A> implements
      * @return this
      */
     public UnarySequence<A> then(UnaryProcedure<? super A> p) {
-        list.add(p);
+        if (p != null) {
+            list.add(p);
+        }
         return this;
     }
 

Modified: commons/proper/functor/trunk/src/test/java/org/apache/commons/functor/core/composite/TestUnarySequence.java
URL: http://svn.apache.org/viewvc/commons/proper/functor/trunk/src/test/java/org/apache/commons/functor/core/composite/TestUnarySequence.java?rev=1363382&r1=1363381&r2=1363382&view=diff
==============================================================================
--- commons/proper/functor/trunk/src/test/java/org/apache/commons/functor/core/composite/TestUnarySequence.java (original)
+++ commons/proper/functor/trunk/src/test/java/org/apache/commons/functor/core/composite/TestUnarySequence.java Thu Jul 19 15:23:19 2012
@@ -17,6 +17,7 @@
 package org.apache.commons.functor.core.composite;
 
 import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
 
 import java.util.ArrayList;
 import java.util.List;
@@ -44,6 +45,26 @@ public class TestUnarySequence extends B
     // ------------------------------------------------------------------------
 
     @Test
+    public void testConstructors() throws Exception {
+        UnarySequence<Object> seq1 = new UnarySequence<Object>((UnaryProcedure<? super Object>)null);
+        UnarySequence<Object> seq2 = new UnarySequence<Object>();
+        assertObjectsAreEqual(seq1, seq2);
+        
+        RunCounter p1 = new RunCounter();
+        RunCounter p2 = new RunCounter();
+        List<UnaryProcedure<? super Object>> iterable = new ArrayList<UnaryProcedure<? super Object>>();
+        iterable.add(p1);
+        iterable.add(p2);
+        UnarySequence<Object> seq3 = new UnarySequence<Object>(iterable);
+        UnarySequence<Object> seq4 = new UnarySequence<Object>(p1, p2);
+        assertObjectsAreEqual(seq3, seq4);
+        
+        UnarySequence<Object> seq5 = new UnarySequence<Object>((Iterable<UnaryProcedure<? super Object>>)null);
+        UnarySequence<Object> seq6 = new UnarySequence<Object>((UnaryProcedure<? super Object>[])null);
+        assertObjectsAreEqual(seq5, seq6);
+    }
+    
+    @Test
     public void testRunZero() throws Exception {
         UnarySequence<String> seq = new UnarySequence<String>();
         seq.run(null);
@@ -110,6 +131,7 @@ public class TestUnarySequence extends B
         }
 
         assertObjectsAreNotEqual(p,new NoOp());
+        assertFalse(p.equals(null));
     }
 
     // Classes



Re: svn commit: r1363382 - in /commons/proper/functor/trunk/src: main/java/org/apache/commons/functor/core/composite/UnarySequence.java test/java/org/apache/commons/functor/core/composite/TestUnarySequence.java

Posted by "Bruno P. Kinoshita" <br...@yahoo.com.br>.
Hi Sebb!

> Also it may be worth adding the commit message header to the JIRA
> issue when resolving it.
>
> This used to be done by a JIRA plugin but that broke when JIRA was
> upgraded recently.

Hmm, that's true indeed. In the Jenkins project, when you include the issue 

number in your commit, the commit log is included in the issue in JIRA (and if 

you include FIXED the issue is marked as Resolved). I think that's similar to what 

the JIRA plugin used to do, right? 

In Jenkins project a script [1] is used to monitor the GitHub repositories (core and plugins) 

and update JIRA. I used this same script + cron in a project for a local company to 

track the changes from SVN and update issues in Mantis.

> It can be very useful when reviewing JIRA issues later.

+1 Would it be worth to include this information as a recommendation under the 

Developers section in the commons Wiki page [2] or somewhere else maybe? 


I finished working on FUNCTOR-3 and tried to follow Simo's and yours advices :-) 


Thank you very much!!!

[1] https://github.com/jenkinsci/backend-jenkins-plugin-changes-plugin
[2] http://wiki.apache.org/commons/FrontPage

Bruno P. Kinoshita
http://kinoshita.eti.br
http://tupilabs.com


----- Original Message -----
> From: sebb <se...@gmail.com>
> To: Commons Developers List <de...@commons.apache.org>; Bruno P. Kinoshita <br...@yahoo.com.br>
> Cc: 
> Sent: Thursday, 19 July 2012 4:44 PM
> Subject: Re: svn commit: r1363382 - in /commons/proper/functor/trunk/src: main/java/org/apache/commons/functor/core/composite/UnarySequence.java test/java/org/apache/commons/functor/core/composite/TestUnarySequence.java
> 
> On 19 July 2012 19:09, Bruno P. Kinoshita <br...@yahoo.com.br> 
> wrote:
>>  Hi Simo!
>> 
>>> two minor observations:
>>> 
>>> * we usually mark resolved issue with [FUNCTOR-XX] rather than FIXED
>>> FUNCTOR-XX - not a big deal, but feel free to modify the log message;
>> 
>>  Thanks for the heads up! I've updated the log message and will try to 
> remember this in the next time.
>> 
>>> * can you please track the issue in the src/main/changes.xml file?
>> 
>> 
>>  Ops, sorry. I always forget to update changes.xml. Already done too.
> 
> Also it may be worth adding the commit message header to the JIRA
> issue when resolving it.
> 
> For example:
> 
>>>> 
> URL: http://svn.apache.org/viewvc?rev=1363382&view=rev
> Log:
> FIXED FUNCTOR-21: Added an extra verification in the then() method of
> UnarySequence to avoid the NPE. Tests in place.
> 
> Modified:
>     
> commons/proper/functor/trunk/src/main/java/org/apache/commons/functor/core/composite/UnarySequence.java
>     
> commons/proper/functor/trunk/src/test/java/org/apache/commons/functor/core/composite/TestUnarySequence.java
> <<<
> 
> This used to be done by a JIRA plugin but that broke when JIRA was
> upgraded recently.
> 
> It can be very useful when reviewing JIRA issues later.
> 
>>  Many thanks! :D
>> 
>> 
>>  Bruno P. Kinoshita
>>  http://kinoshita.eti.br
>>  http://tupilabs.com
>> 
>> 
>>> ________________________________
>>>  From: Simone Tripodi <si...@apache.org>
>>> To: dev@commons.apache.org
>>> Sent: Thursday, 19 July 2012 1:05 PM
>>> Subject: Re: svn commit: r1363382 - in 
> /commons/proper/functor/trunk/src: 
> main/java/org/apache/commons/functor/core/composite/UnarySequence.java 
> test/java/org/apache/commons/functor/core/composite/TestUnarySequence.java
>>> 
>>> very good, I was waiting for you! :)
>>> 
>>> two minor observations:
>>> 
>>> * we usually mark resolved issue with [FUNCTOR-XX] rather than FIXED
>>> FUNCTOR-XX - not a big deal, but feel free to modify the log message;
>>> 
>>> * can you please track the issue in the src/main/changes.xml file?
>>> 
>>> many thanks in advance, all the best!
>>> -Simo
>>> 
>>> http://people.apache.org/~simonetripodi/
>>> http://simonetripodi.livejournal.com/
>>> http://twitter.com/simonetripodi
>>> http://www.99soft.org/
>>> 
>>> 
>>> On Thu, Jul 19, 2012 at 5:23 PM,  <ki...@apache.org> wrote:
>>>>  Author: kinow
>>>>  Date: Thu Jul 19 15:23:19 2012
>>>>  New Revision: 1363382
>>>> 
>>>>  URL: http://svn.apache.org/viewvc?rev=1363382&view=rev
>>>>  Log:
>>>>  FIXED FUNCTOR-21: Added an extra verification in the then() method 
> of UnarySequence to avoid the NPE. Tests in place.
>>>> 
>>>>  Modified:
>>>>     
> commons/proper/functor/trunk/src/main/java/org/apache/commons/functor/core/composite/UnarySequence.java
>>>>     
> commons/proper/functor/trunk/src/test/java/org/apache/commons/functor/core/composite/TestUnarySequence.java
>>>> 
>>>>  Modified: 
> commons/proper/functor/trunk/src/main/java/org/apache/commons/functor/core/composite/UnarySequence.java
>>>>  URL: 
> http://svn.apache.org/viewvc/commons/proper/functor/trunk/src/main/java/org/apache/commons/functor/core/composite/UnarySequence.java?rev=1363382&r1=1363381&r2=1363382&view=diff
>>>> 
> ==============================================================================
>>>>  --- 
> commons/proper/functor/trunk/src/main/java/org/apache/commons/functor/core/composite/UnarySequence.java 
> (original)
>>>>  +++ 
> commons/proper/functor/trunk/src/main/java/org/apache/commons/functor/core/composite/UnarySequence.java 
> Thu Jul 19 15:23:19 2012
>>>>  @@ -98,7 +98,9 @@ public class UnarySequence<A> implements
>>>>        * @return this
>>>>        */
>>>>       public UnarySequence<A> then(UnaryProcedure<? super 
> A> p) {
>>>>  -        list.add(p);
>>>>  +        if (p != null) {
>>>>  +            list.add(p);
>>>>  +        }
>>>>           return this;
>>>>       }
>>>> 
>>>> 
>>>>  Modified: 
> commons/proper/functor/trunk/src/test/java/org/apache/commons/functor/core/composite/TestUnarySequence.java
>>>>  URL: 
> http://svn.apache.org/viewvc/commons/proper/functor/trunk/src/test/java/org/apache/commons/functor/core/composite/TestUnarySequence.java?rev=1363382&r1=1363381&r2=1363382&view=diff
>>>> 
> ==============================================================================
>>>>  --- 
> commons/proper/functor/trunk/src/test/java/org/apache/commons/functor/core/composite/TestUnarySequence.java 
> (original)
>>>>  +++ 
> commons/proper/functor/trunk/src/test/java/org/apache/commons/functor/core/composite/TestUnarySequence.java 
> Thu Jul 19 15:23:19 2012
>>>>  @@ -17,6 +17,7 @@
>>>>   package org.apache.commons.functor.core.composite;
>>>> 
>>>>   import static org.junit.Assert.assertEquals;
>>>>  +import static org.junit.Assert.assertFalse;
>>>> 
>>>>   import java.util.ArrayList;
>>>>   import java.util.List;
>>>>  @@ -44,6 +45,26 @@ public class TestUnarySequence extends B
>>>>       // 
> ------------------------------------------------------------------------
>>>> 
>>>>       @Test
>>>>  +    public void testConstructors() throws Exception {
>>>>  +        UnarySequence<Object> seq1 = new 
> UnarySequence<Object>((UnaryProcedure<? super Object>)null);
>>>>  +        UnarySequence<Object> seq2 = new 
> UnarySequence<Object>();
>>>>  +        assertObjectsAreEqual(seq1, seq2);
>>>>  +
>>>>  +        RunCounter p1 = new RunCounter();
>>>>  +        RunCounter p2 = new RunCounter();
>>>>  +        List<UnaryProcedure<? super Object>> iterable 
> = new ArrayList<UnaryProcedure<? super Object>>();
>>>>  +        iterable.add(p1);
>>>>  +        iterable.add(p2);
>>>>  +        UnarySequence<Object> seq3 = new 
> UnarySequence<Object>(iterable);
>>>>  +        UnarySequence<Object> seq4 = new 
> UnarySequence<Object>(p1, p2);
>>>>  +        assertObjectsAreEqual(seq3, seq4);
>>>>  +
>>>>  +        UnarySequence<Object> seq5 = new 
> UnarySequence<Object>((Iterable<UnaryProcedure<? super 
> Object>>)null);
>>>>  +        UnarySequence<Object> seq6 = new 
> UnarySequence<Object>((UnaryProcedure<? super Object>[])null);
>>>>  +        assertObjectsAreEqual(seq5, seq6);
>>>>  +    }
>>>>  +
>>>>  +    @Test
>>>>       public void testRunZero() throws Exception {
>>>>           UnarySequence<String> seq = new 
> UnarySequence<String>();
>>>>           seq.run(null);
>>>>  @@ -110,6 +131,7 @@ public class TestUnarySequence extends B
>>>>           }
>>>> 
>>>>           assertObjectsAreNotEqual(p,new NoOp());
>>>>  +        assertFalse(p.equals(null));
>>>>       }
>>>> 
>>>>       // Classes
>>>> 
>>>> 
>>> 
>>> ---------------------------------------------------------------------
>>> 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
>> 
> 

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


Re: svn commit: r1363382 - in /commons/proper/functor/trunk/src: main/java/org/apache/commons/functor/core/composite/UnarySequence.java test/java/org/apache/commons/functor/core/composite/TestUnarySequence.java

Posted by sebb <se...@gmail.com>.
On 19 July 2012 19:09, Bruno P. Kinoshita <br...@yahoo.com.br> wrote:
> Hi Simo!
>
>>two minor observations:
>>
>>* we usually mark resolved issue with [FUNCTOR-XX] rather than FIXED
>>FUNCTOR-XX - not a big deal, but feel free to modify the log message;
>
> Thanks for the heads up! I've updated the log message and will try to remember this in the next time.
>
>>* can you please track the issue in the src/main/changes.xml file?
>
>
> Ops, sorry. I always forget to update changes.xml. Already done too.

Also it may be worth adding the commit message header to the JIRA
issue when resolving it.

For example:

>>>
URL: http://svn.apache.org/viewvc?rev=1363382&view=rev
Log:
FIXED FUNCTOR-21: Added an extra verification in the then() method of
UnarySequence to avoid the NPE. Tests in place.

Modified:
    commons/proper/functor/trunk/src/main/java/org/apache/commons/functor/core/composite/UnarySequence.java
    commons/proper/functor/trunk/src/test/java/org/apache/commons/functor/core/composite/TestUnarySequence.java
<<<

This used to be done by a JIRA plugin but that broke when JIRA was
upgraded recently.

It can be very useful when reviewing JIRA issues later.

> Many thanks! :D
>
>
> Bruno P. Kinoshita
> http://kinoshita.eti.br
> http://tupilabs.com
>
>
>>________________________________
>> From: Simone Tripodi <si...@apache.org>
>>To: dev@commons.apache.org
>>Sent: Thursday, 19 July 2012 1:05 PM
>>Subject: Re: svn commit: r1363382 - in /commons/proper/functor/trunk/src: main/java/org/apache/commons/functor/core/composite/UnarySequence.java test/java/org/apache/commons/functor/core/composite/TestUnarySequence.java
>>
>>very good, I was waiting for you! :)
>>
>>two minor observations:
>>
>>* we usually mark resolved issue with [FUNCTOR-XX] rather than FIXED
>>FUNCTOR-XX - not a big deal, but feel free to modify the log message;
>>
>>* can you please track the issue in the src/main/changes.xml file?
>>
>>many thanks in advance, all the best!
>>-Simo
>>
>>http://people.apache.org/~simonetripodi/
>>http://simonetripodi.livejournal.com/
>>http://twitter.com/simonetripodi
>>http://www.99soft.org/
>>
>>
>>On Thu, Jul 19, 2012 at 5:23 PM,  <ki...@apache.org> wrote:
>>> Author: kinow
>>> Date: Thu Jul 19 15:23:19 2012
>>> New Revision: 1363382
>>>
>>> URL: http://svn.apache.org/viewvc?rev=1363382&view=rev
>>> Log:
>>> FIXED FUNCTOR-21: Added an extra verification in the then() method of UnarySequence to avoid the NPE. Tests in place.
>>>
>>> Modified:
>>>     commons/proper/functor/trunk/src/main/java/org/apache/commons/functor/core/composite/UnarySequence.java
>>>     commons/proper/functor/trunk/src/test/java/org/apache/commons/functor/core/composite/TestUnarySequence.java
>>>
>>> Modified: commons/proper/functor/trunk/src/main/java/org/apache/commons/functor/core/composite/UnarySequence.java
>>> URL: http://svn.apache.org/viewvc/commons/proper/functor/trunk/src/main/java/org/apache/commons/functor/core/composite/UnarySequence.java?rev=1363382&r1=1363381&r2=1363382&view=diff
>>> ==============================================================================
>>> --- commons/proper/functor/trunk/src/main/java/org/apache/commons/functor/core/composite/UnarySequence.java (original)
>>> +++ commons/proper/functor/trunk/src/main/java/org/apache/commons/functor/core/composite/UnarySequence.java Thu Jul 19 15:23:19 2012
>>> @@ -98,7 +98,9 @@ public class UnarySequence<A> implements
>>>       * @return this
>>>       */
>>>      public UnarySequence<A> then(UnaryProcedure<? super A> p) {
>>> -        list.add(p);
>>> +        if (p != null) {
>>> +            list.add(p);
>>> +        }
>>>          return this;
>>>      }
>>>
>>>
>>> Modified: commons/proper/functor/trunk/src/test/java/org/apache/commons/functor/core/composite/TestUnarySequence.java
>>> URL: http://svn.apache.org/viewvc/commons/proper/functor/trunk/src/test/java/org/apache/commons/functor/core/composite/TestUnarySequence.java?rev=1363382&r1=1363381&r2=1363382&view=diff
>>> ==============================================================================
>>> --- commons/proper/functor/trunk/src/test/java/org/apache/commons/functor/core/composite/TestUnarySequence.java (original)
>>> +++ commons/proper/functor/trunk/src/test/java/org/apache/commons/functor/core/composite/TestUnarySequence.java Thu Jul 19 15:23:19 2012
>>> @@ -17,6 +17,7 @@
>>>  package org.apache.commons.functor.core.composite;
>>>
>>>  import static org.junit.Assert.assertEquals;
>>> +import static org.junit.Assert.assertFalse;
>>>
>>>  import java.util.ArrayList;
>>>  import java.util.List;
>>> @@ -44,6 +45,26 @@ public class TestUnarySequence extends B
>>>      // ------------------------------------------------------------------------
>>>
>>>      @Test
>>> +    public void testConstructors() throws Exception {
>>> +        UnarySequence<Object> seq1 = new UnarySequence<Object>((UnaryProcedure<? super Object>)null);
>>> +        UnarySequence<Object> seq2 = new UnarySequence<Object>();
>>> +        assertObjectsAreEqual(seq1, seq2);
>>> +
>>> +        RunCounter p1 = new RunCounter();
>>> +        RunCounter p2 = new RunCounter();
>>> +        List<UnaryProcedure<? super Object>> iterable = new ArrayList<UnaryProcedure<? super Object>>();
>>> +        iterable.add(p1);
>>> +        iterable.add(p2);
>>> +        UnarySequence<Object> seq3 = new UnarySequence<Object>(iterable);
>>> +        UnarySequence<Object> seq4 = new UnarySequence<Object>(p1, p2);
>>> +        assertObjectsAreEqual(seq3, seq4);
>>> +
>>> +        UnarySequence<Object> seq5 = new UnarySequence<Object>((Iterable<UnaryProcedure<? super Object>>)null);
>>> +        UnarySequence<Object> seq6 = new UnarySequence<Object>((UnaryProcedure<? super Object>[])null);
>>> +        assertObjectsAreEqual(seq5, seq6);
>>> +    }
>>> +
>>> +    @Test
>>>      public void testRunZero() throws Exception {
>>>          UnarySequence<String> seq = new UnarySequence<String>();
>>>          seq.run(null);
>>> @@ -110,6 +131,7 @@ public class TestUnarySequence extends B
>>>          }
>>>
>>>          assertObjectsAreNotEqual(p,new NoOp());
>>> +        assertFalse(p.equals(null));
>>>      }
>>>
>>>      // Classes
>>>
>>>
>>
>>---------------------------------------------------------------------
>>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
>

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


Re: svn commit: r1363382 - in /commons/proper/functor/trunk/src: main/java/org/apache/commons/functor/core/composite/UnarySequence.java test/java/org/apache/commons/functor/core/composite/TestUnarySequence.java

Posted by "Bruno P. Kinoshita" <br...@yahoo.com.br>.
Hi Simo!

>two minor observations:
>
>* we usually mark resolved issue with [FUNCTOR-XX] rather than FIXED
>FUNCTOR-XX - not a big deal, but feel free to modify the log message;

Thanks for the heads up! I've updated the log message and will try to remember this in the next time.

>* can you please track the issue in the src/main/changes.xml file?


Ops, sorry. I always forget to update changes.xml. Already done too.

Many thanks! :D


Bruno P. Kinoshita
http://kinoshita.eti.br
http://tupilabs.com


>________________________________
> From: Simone Tripodi <si...@apache.org>
>To: dev@commons.apache.org 
>Sent: Thursday, 19 July 2012 1:05 PM
>Subject: Re: svn commit: r1363382 - in /commons/proper/functor/trunk/src: main/java/org/apache/commons/functor/core/composite/UnarySequence.java test/java/org/apache/commons/functor/core/composite/TestUnarySequence.java
> 
>very good, I was waiting for you! :)
>
>two minor observations:
>
>* we usually mark resolved issue with [FUNCTOR-XX] rather than FIXED
>FUNCTOR-XX - not a big deal, but feel free to modify the log message;
>
>* can you please track the issue in the src/main/changes.xml file?
>
>many thanks in advance, all the best!
>-Simo
>
>http://people.apache.org/~simonetripodi/
>http://simonetripodi.livejournal.com/
>http://twitter.com/simonetripodi
>http://www.99soft.org/
>
>
>On Thu, Jul 19, 2012 at 5:23 PM,  <ki...@apache.org> wrote:
>> Author: kinow
>> Date: Thu Jul 19 15:23:19 2012
>> New Revision: 1363382
>>
>> URL: http://svn.apache.org/viewvc?rev=1363382&view=rev
>> Log:
>> FIXED FUNCTOR-21: Added an extra verification in the then() method of UnarySequence to avoid the NPE. Tests in place.
>>
>> Modified:
>>     commons/proper/functor/trunk/src/main/java/org/apache/commons/functor/core/composite/UnarySequence.java
>>     commons/proper/functor/trunk/src/test/java/org/apache/commons/functor/core/composite/TestUnarySequence.java
>>
>> Modified: commons/proper/functor/trunk/src/main/java/org/apache/commons/functor/core/composite/UnarySequence.java
>> URL: http://svn.apache.org/viewvc/commons/proper/functor/trunk/src/main/java/org/apache/commons/functor/core/composite/UnarySequence.java?rev=1363382&r1=1363381&r2=1363382&view=diff
>> ==============================================================================
>> --- commons/proper/functor/trunk/src/main/java/org/apache/commons/functor/core/composite/UnarySequence.java (original)
>> +++ commons/proper/functor/trunk/src/main/java/org/apache/commons/functor/core/composite/UnarySequence.java Thu Jul 19 15:23:19 2012
>> @@ -98,7 +98,9 @@ public class UnarySequence<A> implements
>>       * @return this
>>       */
>>      public UnarySequence<A> then(UnaryProcedure<? super A> p) {
>> -        list.add(p);
>> +        if (p != null) {
>> +            list.add(p);
>> +        }
>>          return this;
>>      }
>>
>>
>> Modified: commons/proper/functor/trunk/src/test/java/org/apache/commons/functor/core/composite/TestUnarySequence.java
>> URL: http://svn.apache.org/viewvc/commons/proper/functor/trunk/src/test/java/org/apache/commons/functor/core/composite/TestUnarySequence.java?rev=1363382&r1=1363381&r2=1363382&view=diff
>> ==============================================================================
>> --- commons/proper/functor/trunk/src/test/java/org/apache/commons/functor/core/composite/TestUnarySequence.java (original)
>> +++ commons/proper/functor/trunk/src/test/java/org/apache/commons/functor/core/composite/TestUnarySequence.java Thu Jul 19 15:23:19 2012
>> @@ -17,6 +17,7 @@
>>  package org.apache.commons.functor.core.composite;
>>
>>  import static org.junit.Assert.assertEquals;
>> +import static org.junit.Assert.assertFalse;
>>
>>  import java.util.ArrayList;
>>  import java.util.List;
>> @@ -44,6 +45,26 @@ public class TestUnarySequence extends B
>>      // ------------------------------------------------------------------------
>>
>>      @Test
>> +    public void testConstructors() throws Exception {
>> +        UnarySequence<Object> seq1 = new UnarySequence<Object>((UnaryProcedure<? super Object>)null);
>> +        UnarySequence<Object> seq2 = new UnarySequence<Object>();
>> +        assertObjectsAreEqual(seq1, seq2);
>> +
>> +        RunCounter p1 = new RunCounter();
>> +        RunCounter p2 = new RunCounter();
>> +        List<UnaryProcedure<? super Object>> iterable = new ArrayList<UnaryProcedure<? super Object>>();
>> +        iterable.add(p1);
>> +        iterable.add(p2);
>> +        UnarySequence<Object> seq3 = new UnarySequence<Object>(iterable);
>> +        UnarySequence<Object> seq4 = new UnarySequence<Object>(p1, p2);
>> +        assertObjectsAreEqual(seq3, seq4);
>> +
>> +        UnarySequence<Object> seq5 = new UnarySequence<Object>((Iterable<UnaryProcedure<? super Object>>)null);
>> +        UnarySequence<Object> seq6 = new UnarySequence<Object>((UnaryProcedure<? super Object>[])null);
>> +        assertObjectsAreEqual(seq5, seq6);
>> +    }
>> +
>> +    @Test
>>      public void testRunZero() throws Exception {
>>          UnarySequence<String> seq = new UnarySequence<String>();
>>          seq.run(null);
>> @@ -110,6 +131,7 @@ public class TestUnarySequence extends B
>>          }
>>
>>          assertObjectsAreNotEqual(p,new NoOp());
>> +        assertFalse(p.equals(null));
>>      }
>>
>>      // Classes
>>
>>
>
>---------------------------------------------------------------------
>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: r1363382 - in /commons/proper/functor/trunk/src: main/java/org/apache/commons/functor/core/composite/UnarySequence.java test/java/org/apache/commons/functor/core/composite/TestUnarySequence.java

Posted by Simone Tripodi <si...@apache.org>.
very good, I was waiting for you! :)

two minor observations:

 * we usually mark resolved issue with [FUNCTOR-XX] rather than FIXED
FUNCTOR-XX - not a big deal, but feel free to modify the log message;

 * can you please track the issue in the src/main/changes.xml file?

many thanks in advance, all the best!
-Simo

http://people.apache.org/~simonetripodi/
http://simonetripodi.livejournal.com/
http://twitter.com/simonetripodi
http://www.99soft.org/


On Thu, Jul 19, 2012 at 5:23 PM,  <ki...@apache.org> wrote:
> Author: kinow
> Date: Thu Jul 19 15:23:19 2012
> New Revision: 1363382
>
> URL: http://svn.apache.org/viewvc?rev=1363382&view=rev
> Log:
> FIXED FUNCTOR-21: Added an extra verification in the then() method of UnarySequence to avoid the NPE. Tests in place.
>
> Modified:
>     commons/proper/functor/trunk/src/main/java/org/apache/commons/functor/core/composite/UnarySequence.java
>     commons/proper/functor/trunk/src/test/java/org/apache/commons/functor/core/composite/TestUnarySequence.java
>
> Modified: commons/proper/functor/trunk/src/main/java/org/apache/commons/functor/core/composite/UnarySequence.java
> URL: http://svn.apache.org/viewvc/commons/proper/functor/trunk/src/main/java/org/apache/commons/functor/core/composite/UnarySequence.java?rev=1363382&r1=1363381&r2=1363382&view=diff
> ==============================================================================
> --- commons/proper/functor/trunk/src/main/java/org/apache/commons/functor/core/composite/UnarySequence.java (original)
> +++ commons/proper/functor/trunk/src/main/java/org/apache/commons/functor/core/composite/UnarySequence.java Thu Jul 19 15:23:19 2012
> @@ -98,7 +98,9 @@ public class UnarySequence<A> implements
>       * @return this
>       */
>      public UnarySequence<A> then(UnaryProcedure<? super A> p) {
> -        list.add(p);
> +        if (p != null) {
> +            list.add(p);
> +        }
>          return this;
>      }
>
>
> Modified: commons/proper/functor/trunk/src/test/java/org/apache/commons/functor/core/composite/TestUnarySequence.java
> URL: http://svn.apache.org/viewvc/commons/proper/functor/trunk/src/test/java/org/apache/commons/functor/core/composite/TestUnarySequence.java?rev=1363382&r1=1363381&r2=1363382&view=diff
> ==============================================================================
> --- commons/proper/functor/trunk/src/test/java/org/apache/commons/functor/core/composite/TestUnarySequence.java (original)
> +++ commons/proper/functor/trunk/src/test/java/org/apache/commons/functor/core/composite/TestUnarySequence.java Thu Jul 19 15:23:19 2012
> @@ -17,6 +17,7 @@
>  package org.apache.commons.functor.core.composite;
>
>  import static org.junit.Assert.assertEquals;
> +import static org.junit.Assert.assertFalse;
>
>  import java.util.ArrayList;
>  import java.util.List;
> @@ -44,6 +45,26 @@ public class TestUnarySequence extends B
>      // ------------------------------------------------------------------------
>
>      @Test
> +    public void testConstructors() throws Exception {
> +        UnarySequence<Object> seq1 = new UnarySequence<Object>((UnaryProcedure<? super Object>)null);
> +        UnarySequence<Object> seq2 = new UnarySequence<Object>();
> +        assertObjectsAreEqual(seq1, seq2);
> +
> +        RunCounter p1 = new RunCounter();
> +        RunCounter p2 = new RunCounter();
> +        List<UnaryProcedure<? super Object>> iterable = new ArrayList<UnaryProcedure<? super Object>>();
> +        iterable.add(p1);
> +        iterable.add(p2);
> +        UnarySequence<Object> seq3 = new UnarySequence<Object>(iterable);
> +        UnarySequence<Object> seq4 = new UnarySequence<Object>(p1, p2);
> +        assertObjectsAreEqual(seq3, seq4);
> +
> +        UnarySequence<Object> seq5 = new UnarySequence<Object>((Iterable<UnaryProcedure<? super Object>>)null);
> +        UnarySequence<Object> seq6 = new UnarySequence<Object>((UnaryProcedure<? super Object>[])null);
> +        assertObjectsAreEqual(seq5, seq6);
> +    }
> +
> +    @Test
>      public void testRunZero() throws Exception {
>          UnarySequence<String> seq = new UnarySequence<String>();
>          seq.run(null);
> @@ -110,6 +131,7 @@ public class TestUnarySequence extends B
>          }
>
>          assertObjectsAreNotEqual(p,new NoOp());
> +        assertFalse(p.equals(null));
>      }
>
>      // Classes
>
>

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