[
https://issues.apache.org/jira/browse/WINK-37?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12727640#action_12727640
]
Bryant Luk commented on WINK-37:
--------------------------------
Just out of curiosity but when reading the JavaDoc, is it the general belief
that we never receive null? (i.e. in Providers.getMessageBodyWriter() are we
suppose to defend against a null Annotations[] parameter and just assume it's
an empty array?). The JavaDoc doesn't seem to imply one way or another. I
looked at java.util.Map for instance and they're much more explicit about NPEs,
IllegalArgumentExceptions, etc. Since JAX-RS JavaDoc doesn't specify, I don't
really have a preference for this.
One other possibility is to be more offensive and throw a NPE immediately in
the code (if (type == null) { throw new NullPointerException("You passed in a
null"); } ). Doing Jason's assert or doing the immediate NPE throw IMO is
better than having a NPE in the stack deeper in the Wink code. If I were to
look at the NPE exception and it was in
ProvidersRegistry.MediaTypeMap.getProvidersByMediaType() for instance, I would
think it's Wink's fault.
> detection of null params to avoid NPE
> -------------------------------------
>
> Key: WINK-37
> URL: https://issues.apache.org/jira/browse/WINK-37
> Project: Wink
> Issue Type: Improvement
> Components: Common
> Affects Versions: 0.1
> Reporter: Mike Rheinheimer
> Attachments: npe_patch.txt
>
>
> I was working on a few bigger integration tests, and ran into some NPEs in
> ProvidersRegistry due to my resource passing null params into ProvidersImpl.*
> methods. Granted, this is something an app or resource should not normally
> do, but I think some protection against NPE would be good here. Please see
> proposed patch with tests.
> The supplied test is a start on building up more ProvidersImpl unittests.
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.