[
https://issues.apache.org/jira/browse/CASSANDRA-1796?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12965728#action_12965728
]
Eric Evans commented on CASSANDRA-1796:
---------------------------------------
Did you actually get an NPE here, or is this a hypothetical? I ask because this
is all inlined in the grammar, there should be no way for it to throw since the
only way this code can run is if the rule matches and INTEGER returns something
parseable by Integer.parseInt.
Actually, if for some reason this _did_ happen, it would constitute a serious
bug in ANTlr, at which point an NPE would probably be preferable to assigning
the value zero.
I think I'd rather leave things more concise (and readable) than protect
against something that won't happen.
> [patch] avoid npes when parsing potentially null strings->Integers
> ------------------------------------------------------------------
>
> Key: CASSANDRA-1796
> URL: https://issues.apache.org/jira/browse/CASSANDRA-1796
> Project: Cassandra
> Issue Type: Bug
> Components: API
> Affects Versions: 0.8
> Environment: ubuntu 10.10 jdk 1.6.17 ant1.8
> Reporter: Dave Brosius
> Assignee: Dave Brosius
> Priority: Trivial
> Fix For: 0.8
>
> Attachments: avoid_npes.diff
>
> Original Estimate: 1h
> Remaining Estimate: 1h
>
> code potentially performs Integer.parseInt(null) which throws NPEs, patch
> guards against this, and returns 0 instead.
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.