[jira] [Created] (FUNCTOR-8) [PATCH] Possible NPE in TransformedGenerator if getWrappedGenerator() is overridden to return null

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

[jira] [Created] (FUNCTOR-8) [PATCH] Possible NPE in TransformedGenerator if getWrappedGenerator() is overridden to return null

Gary D. Gregory (Jira)
[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.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

       
Reply | Threaded
Open this post in threaded view
|

[jira] [Updated] (FUNCTOR-8) [PATCH] Possible NPE in TransformedGenerator if getWrappedGenerator() is overridden to return null

Gary D. Gregory (Jira)

     [ 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.patch

A fix for the NPE in TransformedGenerator.
               

> [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.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

       
Reply | Threaded
Open this post in threaded view
|

[jira] [Updated] (FUNCTOR-8) [PATCH] Possible NPE in TransformedGenerator if getWrappedGenerator() is overridden to return null

Gary D. Gregory (Jira)
In reply to this post by Gary D. Gregory (Jira)

     [ 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

       
Reply | Threaded
Open this post in threaded view
|

[jira] [Resolved] (FUNCTOR-8) [PATCH] Possible NPE in TransformedGenerator if getWrappedGenerator() is overridden to return null

Gary D. Gregory (Jira)
In reply to this post by Gary D. Gregory (Jira)

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

Simone Tripodi resolved FUNCTOR-8.
----------------------------------

       Resolution: Fixed
    Fix Version/s: 1.0
         Assignee: Simone Tripodi

patch applied, see r1344780

thanks once again for contributing, Bruno!
               

> [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
>            Assignee: Simone Tripodi
>             Fix For: 1.0
>
>         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