pdfbox-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "ASF subversion and git services (Jira)" <j...@apache.org>
Subject [jira] [Commented] (PDFBOX-4701) TextPosition.equal() fails after getDir()
Date Sun, 01 Dec 2019 09:17:00 GMT

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

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

Commit 1870668 from Tilman Hausherr in branch 'pdfbox/branches/2.0'
[ https://svn.apache.org/r1870668 ]

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


Mime
View raw message