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

Tilman Hausherr commented on PDFBOX-6121:
-----------------------------------------

It turns out that the patch, while correct in logic, doesn't work because 
ChatGPT deletes the comments internally. I tried several follow up prompts and 
still didn't get a working patch. I asked for the complete code and the 
comments were missing. However it now had a new practical method:
{code:java}
    private <T> T getPropertyAs(String name, Class<T> type)
    {
        Object p = getProperty(name);
        return type.isInstance(p) ? type.cast(p) : null;
    }
{code}

> ClassCastException: class org.apache.xmpbox.type.TextType cannot be cast to 
> class org.apache.xmpbox.type.ArrayProperty in 
> DublinCoreSchema.getCreatorsProperty()
> ----------------------------------------------------------------------------------------------------------------------------------------------------------------
>
>                 Key: PDFBOX-6121
>                 URL: https://issues.apache.org/jira/browse/PDFBOX-6121
>             Project: PDFBox
>          Issue Type: Bug
>          Components: XmpBox
>    Affects Versions: 2.0.35, 3.0.6 PDFBox
>            Reporter: Tilman Hausherr
>            Assignee: Tilman Hausherr
>            Priority: Major
>             Fix For: 2.0.36, 3.0.7 PDFBox, 4.0.0
>
>         Attachments: 004157.pdf, DublinCoreSchema-safe-casts.patch
>
>
> {noformat}
> java.lang.ClassCastException: class org.apache.xmpbox.type.TextType cannot be 
> cast to class org.apache.xmpbox.type.ArrayProperty 
> (org.apache.xmpbox.type.TextType and org.apache.xmpbox.type.ArrayProperty are 
> in unnamed module of loader 'app')
>       at 
> org.apache.xmpbox.schema.DublinCoreSchema.getCreatorsProperty(DublinCoreSchema.java:448)
>       at 
> org.apache.pdfbox.preflight.metadata.SynchronizedMetaDataValidation.analyzeAuthorProperty(SynchronizedMetaDataValidation.java:145)
>       at 
> org.apache.pdfbox.preflight.metadata.SynchronizedMetaDataValidation.validateMetadataSynchronization(SynchronizedMetaDataValidation.java:461)
>       at 
> org.apache.pdfbox.preflight.process.MetadataValidationProcess.validate(MetadataValidationProcess.java:91)
>       at 
> org.apache.pdfbox.preflight.utils.ContextHelper.callValidation(ContextHelper.java:102)
>       at 
> org.apache.pdfbox.preflight.utils.ContextHelper.validateElement(ContextHelper.java:141)
>       at 
> org.apache.pdfbox.preflight.PreflightDocument.validate(PreflightDocument.java:157)
> {noformat}



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to