You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@pdfbox.apache.org by "ASF subversion and git services (Jira)" <ji...@apache.org> on 2019/12/01 09:17:00 UTC

[jira] [Commented] (PDFBOX-4701) TextPosition.equal() fails after getDir()

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

ASF subversion and git services commented on PDFBOX-4701:
---------------------------------------------------------

Commit 1870666 from Tilman Hausherr in branch 'pdfbox/branches/issue4569'
[ https://svn.apache.org/r1870666 ]

PDFBOX-4701: do not use mutable fields in equals()

> TextPosition.equal() fails after getDir()
> -----------------------------------------
>
>                 Key: PDFBOX-4701
>                 URL: https://issues.apache.org/jira/browse/PDFBOX-4701
>             Project: PDFBox
>          Issue Type: Bug
>          Components: Text extraction
>    Affects Versions: 2.0.17
>            Reporter: Tilman Hausherr
>            Assignee: Tilman Hausherr
>            Priority: Major
>             Fix For: 2.0.18, 3.0.0 PDFBox
>
>
> From "Esteban R" in the users mailing list:
> {quote}
> This is a simplification of a real life problem: when I compare two TextPositions, equality changes after calling getDir() in one of the TextPositions.
> Code to reproduce:
> {code}
> Matrix m1 = new Matrix(1, 1, 1, 1, 1, 1);
> Matrix m2 = new Matrix(1, 1, 1, 1, 1, 1);
> TextPosition t1 = new TextPosition(0, 1000, 1000, m2, 10, 10, 100, 10, 10, "a", null, null, 10, 10);
> TextPosition t2 = new TextPosition(0, 1000, 1000, m2, 10, 10, 100, 10, 10, "a", null, null, 10, 10);
> System.out.println("Before getDir, equals: "+t1.equals(t2)); //true
> t1.getDir(); //changes direction field!!!
> System.out.println("After getDir, equals: "+t1.equals(t2)); //false!!{code}
> {quote}
> The reason is that mutable fields are used in {{equals()}}.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@pdfbox.apache.org
For additional commands, e-mail: dev-help@pdfbox.apache.org