You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@flume.apache.org by "Hari Shreedharan (Created) (JIRA)" <ji...@apache.org> on 2012/03/05 00:04:59 UTC

[jira] [Created] (FLUME-1018) Context can cause NullPointerException

Context can cause NullPointerException
--------------------------------------

                 Key: FLUME-1018
                 URL: https://issues.apache.org/jira/browse/FLUME-1018
             Project: Flume
          Issue Type: Bug
          Components: Configuration
    Affects Versions: v1.0.0
            Reporter: Hari Shreedharan
            Priority: Minor
             Fix For: v1.1.0


The new get functions in context class like getInteger, getBoolean etc can cause NullPointerException if the configuration key which is being searched is not in the context map. This is because the get<Type>(String key) version is basically a call to get<Type>(String key, null). Therefore it can return null. Java will automatically unbox the value returned by this function if the user code accepts it into a native datatype variable rather than a wrapper object. 

For example int rollInterval = getInteger("RollInterval") would cause a NullPointerException if rollInterval is absent in the context(since getInteger would return null). It is common to accept an Integer object into an int. We should at the least fix the documentation to suggest that this function will return null if the value is not found, and the return value should be an Integer/Boolean/Long object, not their native counter parts.

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

        

[jira] [Commented] (FLUME-1018) Context can cause NullPointerException

Posted by "Brock Noland (Commented) (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/FLUME-1018?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13227578#comment-13227578 ] 

Brock Noland commented on FLUME-1018:
-------------------------------------

Yes, that is why I returned Integer, Long, etc as opposed to the natives. We should update the docs.
                
> Context can cause NullPointerException
> --------------------------------------
>
>                 Key: FLUME-1018
>                 URL: https://issues.apache.org/jira/browse/FLUME-1018
>             Project: Flume
>          Issue Type: Bug
>          Components: Configuration
>    Affects Versions: v1.0.0
>            Reporter: Hari Shreedharan
>            Priority: Minor
>             Fix For: v1.1.0
>
>
> The new get functions in context class like getInteger, getBoolean etc can cause NullPointerException if the configuration key which is being searched is not in the context map. This is because the get<Type>(String key) version is basically a call to get<Type>(String key, null). Therefore it can return null. Java will automatically unbox the value returned by this function if the user code accepts it into a native datatype variable rather than a wrapper object. 
> For example int rollInterval = getInteger("RollInterval") would cause a NullPointerException if rollInterval is absent in the context(since getInteger would return null). It is common to accept an Integer object into an int. We should at the least fix the documentation to suggest that this function will return null if the value is not found, and the return value should be an Integer/Boolean/Long object, not their native counter parts.

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

        

[jira] [Updated] (FLUME-1018) Context can cause NullPointerException

Posted by "Arvind Prabhakar (Updated) (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/FLUME-1018?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Arvind Prabhakar updated FLUME-1018:
------------------------------------

    Resolution: Fixed
        Status: Resolved  (was: Patch Available)

Patch committed. Thanks Brock!
                
> Context can cause NullPointerException
> --------------------------------------
>
>                 Key: FLUME-1018
>                 URL: https://issues.apache.org/jira/browse/FLUME-1018
>             Project: Flume
>          Issue Type: Bug
>          Components: Configuration
>    Affects Versions: v1.0.0
>            Reporter: Hari Shreedharan
>            Assignee: Brock Noland
>            Priority: Minor
>             Fix For: v1.1.0
>
>         Attachments: FLUME-1018-0.patch
>
>
> The new get functions in context class like getInteger, getBoolean etc can cause NullPointerException if the configuration key which is being searched is not in the context map. This is because the get<Type>(String key) version is basically a call to get<Type>(String key, null). Therefore it can return null. Java will automatically unbox the value returned by this function if the user code accepts it into a native datatype variable rather than a wrapper object. 
> For example int rollInterval = getInteger("RollInterval") would cause a NullPointerException if rollInterval is absent in the context(since getInteger would return null). It is common to accept an Integer object into an int. We should at the least fix the documentation to suggest that this function will return null if the value is not found, and the return value should be an Integer/Boolean/Long object, not their native counter parts.

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

        

[jira] [Assigned] (FLUME-1018) Context can cause NullPointerException

Posted by "Brock Noland (Assigned) (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/FLUME-1018?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Brock Noland reassigned FLUME-1018:
-----------------------------------

    Assignee: Brock Noland
    
> Context can cause NullPointerException
> --------------------------------------
>
>                 Key: FLUME-1018
>                 URL: https://issues.apache.org/jira/browse/FLUME-1018
>             Project: Flume
>          Issue Type: Bug
>          Components: Configuration
>    Affects Versions: v1.0.0
>            Reporter: Hari Shreedharan
>            Assignee: Brock Noland
>            Priority: Minor
>             Fix For: v1.1.0
>
>         Attachments: FLUME-1018-0.patch
>
>
> The new get functions in context class like getInteger, getBoolean etc can cause NullPointerException if the configuration key which is being searched is not in the context map. This is because the get<Type>(String key) version is basically a call to get<Type>(String key, null). Therefore it can return null. Java will automatically unbox the value returned by this function if the user code accepts it into a native datatype variable rather than a wrapper object. 
> For example int rollInterval = getInteger("RollInterval") would cause a NullPointerException if rollInterval is absent in the context(since getInteger would return null). It is common to accept an Integer object into an int. We should at the least fix the documentation to suggest that this function will return null if the value is not found, and the return value should be an Integer/Boolean/Long object, not their native counter parts.

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

        

[jira] [Commented] (FLUME-1018) Context can cause NullPointerException

Posted by "jiraposter@reviews.apache.org (Commented) (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/FLUME-1018?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13227603#comment-13227603 ] 

jiraposter@reviews.apache.org commented on FLUME-1018:
------------------------------------------------------


-----------------------------------------------------------
This is an automatically generated e-mail. To reply, visit:
https://reviews.apache.org/r/4292/#review5836
-----------------------------------------------------------

Ship it!


+1

- Arvind


On 2012-03-12 15:08:00, Brock Noland wrote:
bq.  
bq.  -----------------------------------------------------------
bq.  This is an automatically generated e-mail. To reply, visit:
bq.  https://reviews.apache.org/r/4292/
bq.  -----------------------------------------------------------
bq.  
bq.  (Updated 2012-03-12 15:08:00)
bq.  
bq.  
bq.  Review request for Flume.
bq.  
bq.  
bq.  Summary
bq.  -------
bq.  
bq.  Clearly documents that uses will get an NPE if they assign context.get{Integer,Boolean,Long} directly to a primitive and the key is unmapped.
bq.  
bq.  
bq.  This addresses bug FLUME-1018.
bq.      https://issues.apache.org/jira/browse/FLUME-1018
bq.  
bq.  
bq.  Diffs
bq.  -----
bq.  
bq.    flume-ng-core/src/main/java/org/apache/flume/Context.java 0e86f4d 
bq.  
bq.  Diff: https://reviews.apache.org/r/4292/diff
bq.  
bq.  
bq.  Testing
bq.  -------
bq.  
bq.  None, it's a doc only change.
bq.  
bq.  
bq.  Thanks,
bq.  
bq.  Brock
bq.  
bq.


                
> Context can cause NullPointerException
> --------------------------------------
>
>                 Key: FLUME-1018
>                 URL: https://issues.apache.org/jira/browse/FLUME-1018
>             Project: Flume
>          Issue Type: Bug
>          Components: Configuration
>    Affects Versions: v1.0.0
>            Reporter: Hari Shreedharan
>            Assignee: Brock Noland
>            Priority: Minor
>             Fix For: v1.1.0
>
>         Attachments: FLUME-1018-0.patch
>
>
> The new get functions in context class like getInteger, getBoolean etc can cause NullPointerException if the configuration key which is being searched is not in the context map. This is because the get<Type>(String key) version is basically a call to get<Type>(String key, null). Therefore it can return null. Java will automatically unbox the value returned by this function if the user code accepts it into a native datatype variable rather than a wrapper object. 
> For example int rollInterval = getInteger("RollInterval") would cause a NullPointerException if rollInterval is absent in the context(since getInteger would return null). It is common to accept an Integer object into an int. We should at the least fix the documentation to suggest that this function will return null if the value is not found, and the return value should be an Integer/Boolean/Long object, not their native counter parts.

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

        

[jira] [Commented] (FLUME-1018) Context can cause NullPointerException

Posted by "jiraposter@reviews.apache.org (Commented) (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/FLUME-1018?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13227593#comment-13227593 ] 

jiraposter@reviews.apache.org commented on FLUME-1018:
------------------------------------------------------


-----------------------------------------------------------
This is an automatically generated e-mail. To reply, visit:
https://reviews.apache.org/r/4292/
-----------------------------------------------------------

Review request for Flume.


Summary
-------

Clearly documents that uses will get an NPE if they assign context.get{Integer,Boolean,Long} directly to a primitive and the key is unmapped.


This addresses bug FLUME-1018.
    https://issues.apache.org/jira/browse/FLUME-1018


Diffs
-----

  flume-ng-core/src/main/java/org/apache/flume/Context.java 0e86f4d 

Diff: https://reviews.apache.org/r/4292/diff


Testing
-------

None, it's a doc only change.


Thanks,

Brock


                
> Context can cause NullPointerException
> --------------------------------------
>
>                 Key: FLUME-1018
>                 URL: https://issues.apache.org/jira/browse/FLUME-1018
>             Project: Flume
>          Issue Type: Bug
>          Components: Configuration
>    Affects Versions: v1.0.0
>            Reporter: Hari Shreedharan
>            Assignee: Brock Noland
>            Priority: Minor
>             Fix For: v1.1.0
>
>         Attachments: FLUME-1018-0.patch
>
>
> The new get functions in context class like getInteger, getBoolean etc can cause NullPointerException if the configuration key which is being searched is not in the context map. This is because the get<Type>(String key) version is basically a call to get<Type>(String key, null). Therefore it can return null. Java will automatically unbox the value returned by this function if the user code accepts it into a native datatype variable rather than a wrapper object. 
> For example int rollInterval = getInteger("RollInterval") would cause a NullPointerException if rollInterval is absent in the context(since getInteger would return null). It is common to accept an Integer object into an int. We should at the least fix the documentation to suggest that this function will return null if the value is not found, and the return value should be an Integer/Boolean/Long object, not their native counter parts.

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

        

[jira] [Updated] (FLUME-1018) Context can cause NullPointerException

Posted by "Brock Noland (Updated) (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/FLUME-1018?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Brock Noland updated FLUME-1018:
--------------------------------

    Attachment: FLUME-1018-0.patch

Patch from RB attached.
                
> Context can cause NullPointerException
> --------------------------------------
>
>                 Key: FLUME-1018
>                 URL: https://issues.apache.org/jira/browse/FLUME-1018
>             Project: Flume
>          Issue Type: Bug
>          Components: Configuration
>    Affects Versions: v1.0.0
>            Reporter: Hari Shreedharan
>            Priority: Minor
>             Fix For: v1.1.0
>
>         Attachments: FLUME-1018-0.patch
>
>
> The new get functions in context class like getInteger, getBoolean etc can cause NullPointerException if the configuration key which is being searched is not in the context map. This is because the get<Type>(String key) version is basically a call to get<Type>(String key, null). Therefore it can return null. Java will automatically unbox the value returned by this function if the user code accepts it into a native datatype variable rather than a wrapper object. 
> For example int rollInterval = getInteger("RollInterval") would cause a NullPointerException if rollInterval is absent in the context(since getInteger would return null). It is common to accept an Integer object into an int. We should at the least fix the documentation to suggest that this function will return null if the value is not found, and the return value should be an Integer/Boolean/Long object, not their native counter parts.

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

        

[jira] [Updated] (FLUME-1018) Context can cause NullPointerException

Posted by "Brock Noland (Updated) (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/FLUME-1018?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Brock Noland updated FLUME-1018:
--------------------------------

    Status: Patch Available  (was: Open)
    
> Context can cause NullPointerException
> --------------------------------------
>
>                 Key: FLUME-1018
>                 URL: https://issues.apache.org/jira/browse/FLUME-1018
>             Project: Flume
>          Issue Type: Bug
>          Components: Configuration
>    Affects Versions: v1.0.0
>            Reporter: Hari Shreedharan
>            Assignee: Brock Noland
>            Priority: Minor
>             Fix For: v1.1.0
>
>         Attachments: FLUME-1018-0.patch
>
>
> The new get functions in context class like getInteger, getBoolean etc can cause NullPointerException if the configuration key which is being searched is not in the context map. This is because the get<Type>(String key) version is basically a call to get<Type>(String key, null). Therefore it can return null. Java will automatically unbox the value returned by this function if the user code accepts it into a native datatype variable rather than a wrapper object. 
> For example int rollInterval = getInteger("RollInterval") would cause a NullPointerException if rollInterval is absent in the context(since getInteger would return null). It is common to accept an Integer object into an int. We should at the least fix the documentation to suggest that this function will return null if the value is not found, and the return value should be an Integer/Boolean/Long object, not their native counter parts.

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