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

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

Tilman Hausherr created PDFBOX-4701:
---------------------------------------

             Summary: 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
             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