Bug 65165 - [DateValue] DATEVALUE should throw an EvaluationException
Summary: [DateValue] DATEVALUE should throw an EvaluationException
Alias: None
Product: POI
Classification: Unclassified
Component: SS Common (show other bugs)
Version: unspecified
Hardware: PC All
: P2 normal (vote)
Target Milestone: ---
Assignee: POI Developers List
Depends on:
Reported: 2021-03-04 16:32 UTC by Petr Michálek
Modified: 2021-07-28 16:57 UTC (History)
0 users

Patch to DateValue.java (453 bytes, patch)
2021-03-04 16:32 UTC, Petr Michálek
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Petr Michálek 2021-03-04 16:32:27 UTC
Created attachment 37754 [details]
Patch to DateValue.java

In case of wrong input parameters DateValue function breaks formula evaluation.
Patch is attached, please review.
Comment 1 Jakub 2021-04-21 17:51:30 UTC
The patch is needed, if the DateTimeException is not caught it stops evaluation completely. 

However I'm not sure that the ErrorEval.NUM_ERROR as suggested in the proposed patch is the right error code to return. My excel (version 2010) returns ErrorEval.VALUE_INVALID. Same for the case where the text argument is blank or an empty string. 

Also maybe the code can be made simple if we catch the DateTimeException in the existing try block?
Comment 2 Dominik Stadler 2021-04-27 06:19:20 UTC
Can you also provide a small unit-test which verifies this to ensure it stays in-place in the future?
Comment 3 PJ Fanning 2021-07-28 16:57:08 UTC
applied fix using r1891858