You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@flume.apache.org by "Gonzalo Herreros (JIRA)" <ji...@apache.org> on 2015/10/07 14:16:26 UTC

[jira] [Updated] (FLUME-2719) NullPointerException not handled in JSONHandler

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

Gonzalo Herreros updated FLUME-2719:
------------------------------------
    Attachment: FLUME-2719.patch

Proposed patch

> NullPointerException not handled in JSONHandler
> -----------------------------------------------
>
>                 Key: FLUME-2719
>                 URL: https://issues.apache.org/jira/browse/FLUME-2719
>             Project: Flume
>          Issue Type: Bug
>          Components: Sinks+Sources
>    Affects Versions: v1.5.1
>            Reporter: Gonzalo Herreros
>            Priority: Minor
>         Attachments: FLUME-2719.patch
>
>
> When using an http source with JSONHandler, invalid json is handled correctly and a 400 error is returned.
> However an empty body provokes and unhandled NPE in JSONHandler which returns a 500.
> If should either ignore the request or complain the request is invalid.
>     try {
>       eventList = gson.fromJson(reader, listType);
>     } catch (JsonSyntaxException ex) {
>       throw new HTTPBadRequestException("Request has invalid JSON Syntax.", ex);
>     }
>     for (Event e : eventList) {
>       ((JSONEvent) e).setCharset(charset);
>     }
> The GSON API describes that fromJson returns null when the imput is EOF (which is arguable but documented).
> Flume should check for eventList being null before trying to loop
> Always reproduced in all version



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)