You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@oodt.apache.org by "Ricky Nguyen (Created) (JIRA)" <ji...@apache.org> on 2011/10/18 18:57:10 UTC

[jira] [Created] (OODT-337) XMLPSProductHandler methods should return empty lists instead of null

XMLPSProductHandler methods should return empty lists instead of null
---------------------------------------------------------------------

                 Key: OODT-337
                 URL: https://issues.apache.org/jira/browse/OODT-337
             Project: OODT
          Issue Type: Bug
          Components: xmlps
    Affects Versions: 0.4
            Reporter: Ricky Nguyen
            Priority: Trivial
             Fix For: 0.4


XMLPSProductHandler that should return empty lists instead of null

--
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] (OODT-337) XMLPSProductHandler methods should return empty lists instead of null

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

Ricky Nguyen updated OODT-337:
------------------------------

    Attachment: rickdn-oodt-337.patch
    
> XMLPSProductHandler methods should return empty lists instead of null
> ---------------------------------------------------------------------
>
>                 Key: OODT-337
>                 URL: https://issues.apache.org/jira/browse/OODT-337
>             Project: OODT
>          Issue Type: Bug
>          Components: xmlps
>    Affects Versions: 0.4
>            Reporter: Ricky Nguyen
>            Priority: Trivial
>             Fix For: 0.4
>
>         Attachments: rickdn-oodt-337.patch
>
>
> XMLPSProductHandler that should return empty lists instead of null

--
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] [Resolved] (OODT-337) XMLPSProductHandler methods should return empty lists instead of null

Posted by "Chris A. Mattmann (Resolved) (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/OODT-337?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Chris A. Mattmann resolved OODT-337.
------------------------------------

    Resolution: Fixed

- fix applied in r1206977. Thanks, Ricky!
                
> XMLPSProductHandler methods should return empty lists instead of null
> ---------------------------------------------------------------------
>
>                 Key: OODT-337
>                 URL: https://issues.apache.org/jira/browse/OODT-337
>             Project: OODT
>          Issue Type: Bug
>          Components: xmlps
>    Affects Versions: 0.4
>            Reporter: Ricky Nguyen
>            Assignee: Chris A. Mattmann
>            Priority: Trivial
>             Fix For: 0.4
>
>         Attachments: rickdn-oodt-337.patch
>
>
> XMLPSProductHandler that should return empty lists instead of null

--
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] (OODT-337) XMLPSProductHandler methods should return empty lists instead of null

Posted by "Chris A. Mattmann (Commented) (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/OODT-337?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13129866#comment-13129866 ] 

Chris A. Mattmann commented on OODT-337:
----------------------------------------

Hi Ricky: thanks for breaking these issues up. 

I'm wondering: why is this necessary? Returning null is a perfectly valid signal that a method didn't return any results (in fact, even more so than a Collections.EMPTY_LIST). Any particular reason why you are proposing this change?
                
> XMLPSProductHandler methods should return empty lists instead of null
> ---------------------------------------------------------------------
>
>                 Key: OODT-337
>                 URL: https://issues.apache.org/jira/browse/OODT-337
>             Project: OODT
>          Issue Type: Bug
>          Components: xmlps
>    Affects Versions: 0.4
>            Reporter: Ricky Nguyen
>            Priority: Trivial
>             Fix For: 0.4
>
>
> XMLPSProductHandler that should return empty lists instead of null

--
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] (OODT-337) XMLPSProductHandler methods should return empty lists instead of null

Posted by "Ricky Nguyen (Commented) (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/OODT-337?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13129890#comment-13129890 ] 

Ricky Nguyen commented on OODT-337:
-----------------------------------

The concepts apply regardless of language.  I thought was being helpful by providing zero-impact code cleaning tasks while I'm submitting small enhancements.  But if you only want to commit functionality changes, then I'll do that moving forward.
                
> XMLPSProductHandler methods should return empty lists instead of null
> ---------------------------------------------------------------------
>
>                 Key: OODT-337
>                 URL: https://issues.apache.org/jira/browse/OODT-337
>             Project: OODT
>          Issue Type: Bug
>          Components: xmlps
>    Affects Versions: 0.4
>            Reporter: Ricky Nguyen
>            Assignee: Chris A. Mattmann
>            Priority: Trivial
>             Fix For: 0.4
>
>         Attachments: rickdn-oodt-337.patch
>
>
> XMLPSProductHandler that should return empty lists instead of null

--
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] (OODT-337) XMLPSProductHandler methods should return empty lists instead of null

Posted by "Ricky Nguyen (Commented) (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/OODT-337?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13129857#comment-13129857 ] 

Ricky Nguyen commented on OODT-337:
-----------------------------------

must be committed before oodt-336
                
> XMLPSProductHandler methods should return empty lists instead of null
> ---------------------------------------------------------------------
>
>                 Key: OODT-337
>                 URL: https://issues.apache.org/jira/browse/OODT-337
>             Project: OODT
>          Issue Type: Bug
>          Components: xmlps
>    Affects Versions: 0.4
>            Reporter: Ricky Nguyen
>            Priority: Trivial
>             Fix For: 0.4
>
>
> XMLPSProductHandler that should return empty lists instead of null

--
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] (OODT-337) XMLPSProductHandler methods should return empty lists instead of null

Posted by "Ricky Nguyen (Commented) (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/OODT-337?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13129871#comment-13129871 ] 

Ricky Nguyen commented on OODT-337:
-----------------------------------

Then code that uses the results doesn't ever have to check for null:

{code}
for (String s : thing.getStrings()) {
// do something
}
{code}

versus

{code}
List<String> list = thing.getStrings();
if (list != null) {
  for (String s : list) {
    // do something
  }
}
{code}
                
> XMLPSProductHandler methods should return empty lists instead of null
> ---------------------------------------------------------------------
>
>                 Key: OODT-337
>                 URL: https://issues.apache.org/jira/browse/OODT-337
>             Project: OODT
>          Issue Type: Bug
>          Components: xmlps
>    Affects Versions: 0.4
>            Reporter: Ricky Nguyen
>            Priority: Trivial
>             Fix For: 0.4
>
>
> XMLPSProductHandler that should return empty lists instead of null

--
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] (OODT-337) XMLPSProductHandler methods should return empty lists instead of null

Posted by "Chris A. Mattmann (Commented) (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/OODT-337?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13129897#comment-13129897 ] 

Chris A. Mattmann commented on OODT-337:
----------------------------------------

bq. The concepts apply regardless of language.

Which ones -- you weren't specific. You pasted me a stackoverflow article that has 10-20 references in it. Which ones?

bq. I thought was being helpful by providing zero-impact code cleaning tasks while I'm submitting small enhancements

Changing code just to change code, in addition to small enhancements, conflates the intention of the patch. So, kudos for breaking it up into separate patches, my point is, you made a statement: 

{quote}fixed some methods in XMLPSProductHandler that should return empty lists instead of null (unit test was throwing NPE's){quote}

- *should* is a matter of preference.
- *fixed* implies it was broken, it wasn't.

                
> XMLPSProductHandler methods should return empty lists instead of null
> ---------------------------------------------------------------------
>
>                 Key: OODT-337
>                 URL: https://issues.apache.org/jira/browse/OODT-337
>             Project: OODT
>          Issue Type: Bug
>          Components: xmlps
>    Affects Versions: 0.4
>            Reporter: Ricky Nguyen
>            Assignee: Chris A. Mattmann
>            Priority: Trivial
>             Fix For: 0.4
>
>         Attachments: rickdn-oodt-337.patch
>
>
> XMLPSProductHandler that should return empty lists instead of null

--
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] (OODT-337) XMLPSProductHandler methods should return empty lists instead of null

Posted by "Chris A. Mattmann (Commented) (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/OODT-337?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13129885#comment-13129885 ] 

Chris A. Mattmann commented on OODT-337:
----------------------------------------

Pasting example code (not from the project) and pointing me to C# isn't exactly convincing me of anything.

The fact of the matter is that the unit tests passed before, so your statement about having to change it to 
Collections.EMPTY_LIST to make it work simply isn't true. It worked fine before.

                
> XMLPSProductHandler methods should return empty lists instead of null
> ---------------------------------------------------------------------
>
>                 Key: OODT-337
>                 URL: https://issues.apache.org/jira/browse/OODT-337
>             Project: OODT
>          Issue Type: Bug
>          Components: xmlps
>    Affects Versions: 0.4
>            Reporter: Ricky Nguyen
>            Priority: Trivial
>             Fix For: 0.4
>
>         Attachments: rickdn-oodt-337.patch
>
>
> XMLPSProductHandler that should return empty lists instead of null

--
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] (OODT-337) XMLPSProductHandler methods should return empty lists instead of null

Posted by "Chris A. Mattmann (Commented) (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/OODT-337?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13158175#comment-13158175 ] 

Chris A. Mattmann commented on OODT-337:
----------------------------------------

After thinking about this for a while, I'm fine with this change. Ricky has stepped up and is helping to maintain this component, so he should have a say in some of its design, that largely is equivalent to the way it used to work. 
                
> XMLPSProductHandler methods should return empty lists instead of null
> ---------------------------------------------------------------------
>
>                 Key: OODT-337
>                 URL: https://issues.apache.org/jira/browse/OODT-337
>             Project: OODT
>          Issue Type: Bug
>          Components: xmlps
>    Affects Versions: 0.4
>            Reporter: Ricky Nguyen
>            Assignee: Chris A. Mattmann
>            Priority: Trivial
>             Fix For: 0.4
>
>         Attachments: rickdn-oodt-337.patch
>
>
> XMLPSProductHandler that should return empty lists instead of null

--
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] (OODT-337) XMLPSProductHandler methods should return empty lists instead of null

Posted by "Ricky Nguyen (Commented) (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/OODT-337?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13129874#comment-13129874 ] 

Ricky Nguyen commented on OODT-337:
-----------------------------------

http://stackoverflow.com/questions/1969993/is-it-better-to-return-null-or-empty-collection
                
> XMLPSProductHandler methods should return empty lists instead of null
> ---------------------------------------------------------------------
>
>                 Key: OODT-337
>                 URL: https://issues.apache.org/jira/browse/OODT-337
>             Project: OODT
>          Issue Type: Bug
>          Components: xmlps
>    Affects Versions: 0.4
>            Reporter: Ricky Nguyen
>            Priority: Trivial
>             Fix For: 0.4
>
>
> XMLPSProductHandler that should return empty lists instead of null

--
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] (OODT-337) XMLPSProductHandler methods should return empty lists instead of null

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

Ricky Nguyen updated OODT-337:
------------------------------

    Comment: was deleted

(was: must be committed before oodt-336)
    
> XMLPSProductHandler methods should return empty lists instead of null
> ---------------------------------------------------------------------
>
>                 Key: OODT-337
>                 URL: https://issues.apache.org/jira/browse/OODT-337
>             Project: OODT
>          Issue Type: Bug
>          Components: xmlps
>    Affects Versions: 0.4
>            Reporter: Ricky Nguyen
>            Assignee: Chris A. Mattmann
>            Priority: Trivial
>             Fix For: 0.4
>
>         Attachments: rickdn-oodt-337.patch
>
>
> XMLPSProductHandler that should return empty lists instead of null

--
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] (OODT-337) XMLPSProductHandler methods should return empty lists instead of null

Posted by "Ricky Nguyen (Commented) (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/OODT-337?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13129903#comment-13129903 ] 

Ricky Nguyen commented on OODT-337:
-----------------------------------

http://stackoverflow.com/questions/1969993/is-it-better-to-return-null-or-empty-collection/1970001#1970001

bq. It is considered a best practice to NEVER return null when returning a collection or enumerable. ALWAYS return an empty enumerable/collection. It prevents the aforementioned nonsense, and prevents your car getting egged by co-workers and users of your classes.

as always, there are exceptions to "best practice"
http://stackoverflow.com/questions/1969993/is-it-better-to-return-null-or-empty-collection/1970010#1970010
bq. Depends on your contract and your concrete case. Generally it's best to return empty collections, but sometimes (rarely): (1) null might mean something more specific; (2) your API (contract) might force you to return null.


i will be more careful with my word selection.
                
> XMLPSProductHandler methods should return empty lists instead of null
> ---------------------------------------------------------------------
>
>                 Key: OODT-337
>                 URL: https://issues.apache.org/jira/browse/OODT-337
>             Project: OODT
>          Issue Type: Bug
>          Components: xmlps
>    Affects Versions: 0.4
>            Reporter: Ricky Nguyen
>            Assignee: Chris A. Mattmann
>            Priority: Trivial
>             Fix For: 0.4
>
>         Attachments: rickdn-oodt-337.patch
>
>
> XMLPSProductHandler that should return empty lists instead of null

--
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] (OODT-337) XMLPSProductHandler methods should return empty lists instead of null

Posted by "Chris A. Mattmann (Assigned) (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/OODT-337?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Chris A. Mattmann reassigned OODT-337:
--------------------------------------

    Assignee: Chris A. Mattmann
    
> XMLPSProductHandler methods should return empty lists instead of null
> ---------------------------------------------------------------------
>
>                 Key: OODT-337
>                 URL: https://issues.apache.org/jira/browse/OODT-337
>             Project: OODT
>          Issue Type: Bug
>          Components: xmlps
>    Affects Versions: 0.4
>            Reporter: Ricky Nguyen
>            Assignee: Chris A. Mattmann
>            Priority: Trivial
>             Fix For: 0.4
>
>         Attachments: rickdn-oodt-337.patch
>
>
> XMLPSProductHandler that should return empty lists instead of null

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