commons-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Bruno P. Kinoshita (Updated) (JIRA)" <j...@apache.org>
Subject [jira] [Updated] (FUNCTOR-8) [PATCH] Possible NPE in TransformedGenerator if getWrappedGenerator() is overridden to return null
Date Tue, 01 Nov 2011 12:10:32 GMT

     [ https://issues.apache.org/jira/browse/FUNCTOR-8?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]

Bruno P. Kinoshita updated FUNCTOR-8:
-------------------------------------

    Attachment: FUNCTOR-8-tests.patch

FUNCTOR-8-tests.patch includes a unit test for FUNCTOR-8.patch. 

I attached a separated file for part of this class is also contained in FUNCTOR-7.patch, so
it may help while committing it if FUNCTOR-7 has already been applied. 
                
> [PATCH] Possible NPE in TransformedGenerator if getWrappedGenerator() is overridden to
return null
> --------------------------------------------------------------------------------------------------
>
>                 Key: FUNCTOR-8
>                 URL: https://issues.apache.org/jira/browse/FUNCTOR-8
>             Project: Commons Functor
>          Issue Type: Bug
>         Environment: ubuntu 11.10, sun-jdk-6, eclipse galileo
>            Reporter: Bruno P. Kinoshita
>         Attachments: FUNCTOR-8-tests.patch, FUNCTOR-8.patch
>
>
> If we override getWrappedGenerator method in TransformedGenerator to return null, it
may result in a NullPointerException if hashCode is called.
> Attached the patch for it, and below a snippet of code to reproduce this issue.
>     TransformedGenerator<Integer, Integer> t = new TransformedGenerator<Integer,
Integer>(
> 	new IntegerRange(1, 10), new UnaryFunction<Integer, Integer>() {
> 		public Integer evaluate(Integer obj) {
> 			return obj += 1;
> 		}
>    	}) {
>     	@Override
> 	    protected Generator<? extends Integer> getWrappedGenerator() {
>     		return null;
>     	}
>     };
>     TransformedGenerator<Integer, Integer> t2 = new TransformedGenerator<Integer,
Integer>(
> 	new IntegerRange(1, 10), new UnaryFunction<Integer, Integer>() {
> 		public Integer evaluate(Integer obj) {
> 			return obj -= 1;
> 		}
> 	});
>     System.out.println(t.equals(t2));
>     System.out.println(t.hashCode() == t2.hashCode()); // NPE
> Cheers,
> Bruno P. Kinoshita

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

Mime
View raw message