[
https://issues.apache.org/jira/browse/OFBIZ-11281?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16974144#comment-16974144 ]
Mathieu Lirzin commented on OFBIZ-11281:
----------------------------------------
Hello,
First thanks providing a test case.
I think there is a confusion because "possible NPE" is not a bug per say, but "having an NPE at runtime" is.
To explain the important distinction let me give you an example more meaningful. Imagine some method signature {{Double divide(int x, int y)}} which calculates the result of x/y. Should we consider "Possible {{DivisionByZero}} exception" is a bug ? *No*. Additionally Would it makes sense to return {{null}} when y = 0 ? *Probably not*.
So in general to fix a "NPE happening at runtime" bug, this can be done by either by:
- specifying that the method *must not* be called with certain values that are outside its domain ({{null}}, "" or whatever) and fix the caller.
- specifying explicitly that {{null}} value is part of the domain of the method and adapt the implementation accordingly
Regarding [^OFBIZ-11281_Possible_Nullpointer_in_StringUtil#strToMap.patch] I would like to know why it would be desirable to consider the empty string part of the domain of {{strToMap}} and if there is a reason why {{null}} is returned instead of {{Collections.emptyMap}}?
> Possible Nullpointer in StringUtil#strToMap
> -------------------------------------------
>
> Key: OFBIZ-11281
> URL:
https://issues.apache.org/jira/browse/OFBIZ-11281> Project: OFBiz
> Issue Type: Bug
> Affects Versions: Trunk
> Reporter: Ulrich Heidfeld
> Assignee: Nicolas Malin
> Priority: Critical
> Fix For: 17.12.01, Upcoming Branch, 18.12.01
>
> Attachments: OFBIZ-11281_Possible_Nullpointer_in_StringUtil#strToMap.patch
>
>
> StringUtil#strToMap(String, String, boolean, String) throws Nullpointer for StringUtil.strToMap("", false).
--
This message was sent by Atlassian Jira
(v8.3.4#803005)