hadoop-common-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Bharath Mundlapudi (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (HADOOP-7440) HttpServer.getParameterValues throws NPE for missing parameters
Date Tue, 05 Jul 2011 16:21:16 GMT

    [ https://issues.apache.org/jira/browse/HADOOP-7440?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13059983#comment-13059983

Bharath Mundlapudi commented on HADOOP-7440:

Hi Todd & Devaraj,

I didn't see it was a servlet api. One of the problems we saw with propagating nullness to
clients is that, clients forget to add these null checks. But we fixed case by case basis
since some where fundamental JDK APIs. 

If you just search for how people are using this API, you will note that the following example
will throw NPE.

      String[] paramValues = request.getParameterValues(paramName);
      if (paramValues.length == 1) {
        String paramValue = paramValues[0];
        if (paramValue.length() == 0)
          out.print("<I>No Value</I>");
      } else {
        for(int i=0; i<paramValues.length; i++) {
          out.println("<LI>" + paramValues[i]);

I am proposing, if we are the API users, we should not return null rather return empty array.
This will be much cleaner API. Is there any down side in returning empty array? 

> HttpServer.getParameterValues throws NPE for missing parameters
> ---------------------------------------------------------------
>                 Key: HADOOP-7440
>                 URL: https://issues.apache.org/jira/browse/HADOOP-7440
>             Project: Hadoop Common
>          Issue Type: Bug
>    Affects Versions: 0.23.0
>            Reporter: Todd Lipcon
>            Assignee: Todd Lipcon
>             Fix For: 0.23.0
>         Attachments: hadoop-7440.txt
> If the requested parameter was not specified in the request, the raw request's getParameterValues
function returns null. Thus, trying to access {{unquoteValue.length}} throws NPE.

This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira


View raw message