[ 
https://issues.apache.org/jira/browse/PDFBOX-1803?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13843539#comment-13843539
 ] 

Fred Hansen commented on PDFBOX-1803:
-------------------------------------

Upon careful consideration, a different change seems right for the new 
toCalendar(String, String[]). 

For discussion, we can construct a matrix of possible error conditions and 
treatments: For each condition (null, empty string, illegal date) what should 
be the response (exception, return null, return a dummy value with an illegal 
year)?

h3. toCalendar(String) _deprecated method_
For compatibility, as this bug report suggests, {{null}} should be returned for 
an empty string argument:
    ||       |*Condition*|*current result*|*proposed result*||
    |       |For null input|{{null}}| 
    |       |For empty string|-exception-|+{{null}}+| 
    |       |For illegal date|exception|


h3. toCalendar (String, String[]) _replacement method_
Rather than ever producing a non-Calendar value, I propose to revise this 
method:
    ||       |*Condition*|*current result*|*proposed result*||
    |       |For null input|-{{null}}-|+dummy date+|
    |       |For empty string|dummy date|   
    |       |For illegal date|dummy date|   

Unless there are objections, I will revise toCalendar(String, String[]) so it 
returns a dummy Calendar in all cases.





> StringIndexOutOfBound on DateConverter.toCalendar
> -------------------------------------------------
>
>                 Key: PDFBOX-1803
>                 URL: https://issues.apache.org/jira/browse/PDFBOX-1803
>             Project: PDFBox
>          Issue Type: Bug
>          Components: PDModel, Utilities
>    Affects Versions: 1.8.3
>            Reporter: Eric Leleu
>            Priority: Minor
>         Attachments: PDFBox-DateConverter-Br18.patch, 
> PDFBox-DateConverter-Trunk.patch
>
>
> Some PDF have an empty string as CreationDate &  ModDate in the Information 
> Dictionary.
> According to the PDF specification, this two element are optional.
> My first fix was to test the null & the empty string in the 
> toCalendar(String, String[]) method and I return null if one of the both 
> condition is verified.
> But according to a test case(TestDateUtil) a NullPointer is expected on null 
> value of text. Can you explain why this behaviour has been adopted?
> To fixe this unexpected exception in my execution path, I have added a test 
> on the empty string in the deprecated method toCalendar(String). (Patch in 
> attachment)
> I'm waiting your comment before commit this patch (or change it by my first 
> implementation)
> BR,
> Eric



--
This message was sent by Atlassian JIRA
(v6.1.4#6159)

Reply via email to