[
https://issues.apache.org/jira/browse/PDFBOX-4723?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17190988#comment-17190988
]
Maruan Sahyoun commented on PDFBOX-4723:
----------------------------------------
Thanks [~capSVD] and [~mkl]for the discussion and detailed feedback.
For 2.0 when reverting {{equals}} and {{hashCode}} for {{COSArray}} and
{{COSDictionary}} {{COSStream}} hasn't been reverted which should have done.
Thus my last commit. 2.0 shouldn't change it's behaviour and so keeping it in
COSStream wasn't intented.
Agreed that the {{equals}} and {{hashCode}} implementation for {{COSStream}} is
flawed.
Having said that let's keep the discussion for 3.0. I understand that the
potential change is causing issues (that's why it will come with 3.0 if ever)
but it's also resolving issues which is why the effort initially started
(opening a can of worms). As initially said - for whatever reason - PDFBox is
not consistent in using {{equals}} and {{hashCode}} in it's implementation of
PDF base (COS) objects. And there is nothing wrong in overwriting {{equals}}
and {{hashCode}} (if done correctly) and as such one should expect that when
checking for equality that the result differs from checking for identity. The
same is true for using mutual objects as keys.
Btw. when using {{IdentityHashMap}} reference equality will be used when
comparing elements. So there is a special implementation when such behaviour is
expected.
> Add equals() and hashCode() to PDAnnotation and COS objects
> -----------------------------------------------------------
>
> Key: PDFBOX-4723
> URL: https://issues.apache.org/jira/browse/PDFBOX-4723
> Project: PDFBox
> Issue Type: Sub-task
> Components: PDModel
> Affects Versions: 2.0.18
> Reporter: Maruan Sahyoun
> Assignee: Maruan Sahyoun
> Priority: Major
> Fix For: 3.0.0 PDFBox
>
> Attachments: bird_burst.heic.pdf, image-2020-09-02-13-52-21-370.png,
> image-2020-09-02-13-53-02-622.png, image-2020-09-02-13-54-31-630.png,
> screenshot-1.png
>
>
> In order to proper support removeAll/retainAll for COSArrayList we need to
> detect if entries are in fact duplicates of others. This currently fails as
> even though one might add the same instance of an annotation object multiple
> times to setAnnotations getting the annotations will have individual
> instances. See the discussion at PDFBOX-4669.
> In order to proper support removal we need to be able to detect equality
> where an object is equal if the underlying COSDictionary has the same entries.
--
This message was sent by Atlassian Jira
(v8.3.4#803005)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]