Fop
  1. Fop
  2. FOP-1886

[PATCH] Add type safety to collections in fop.area package (e.a.)

    Details

    • Type: Bug Bug
    • Status: Closed
    • Resolution: Fixed
    • Affects Version/s: trunk
    • Fix Version/s: None
    • Component/s: general
    • Labels:
      None
    • Environment:
      Operating System: All
      Platform: All
    • External issue ID:
      50593

      Description

      Attached patch mostly adds type safety to all Collections used in the area package internally, simplifies some for-loops, eliminates redundant casts and (un)boxing...

      Reason why it's posted as a patch is that it concerns en entire package. If I judge correctly, the only effect should be that after the patch, most of the 'unsafe operation' warnings shift to other packages. The ones remaining are due to operations on external 'unsafe' Collections.

      Most significant impact is likely the change in method signature for the Resolvable interface. Not sure if that is being used by extensions...

      1. toc-error.xml
        1.0 kB
        Matthias Reischenbacher
      2. fop_area.diff
        55 kB
        Andreas L. Delmelle

        Activity

        Hide
        Glenn Adams added a comment -

        batch transition to closed; if someone wishes to restore one of these to resolved in order to perform a verification step, then feel free to do so

        Show
        Glenn Adams added a comment - batch transition to closed; if someone wishes to restore one of these to resolved in order to perform a verification step, then feel free to do so
        Hide
        Andreas L. Delmelle added a comment -

        Note: adding this test to our layoutengine test suite, I noticed that a corresponding update was required in the IFSerializer, which before did not got tested with a bookmark pointing to a non-existing location.

        At any rate, fixed in r1085824 (see: http://svn.apache.org/viewvc?rev=1085824&view=rev)

        Thanks for reporting!

        Show
        Andreas L. Delmelle added a comment - Note: adding this test to our layoutengine test suite, I noticed that a corresponding update was required in the IFSerializer, which before did not got tested with a bookmark pointing to a non-existing location. At any rate, fixed in r1085824 (see: http://svn.apache.org/viewvc?rev=1085824&view=rev ) Thanks for reporting!
        Hide
        Andreas L. Delmelle added a comment -

        (In reply to comment #2)
        >
        > this commit causes a IndexOutOfBoundsException, when there are unresolved
        > bookmark references:
        >
        > java.lang.IndexOutOfBoundsException: Index: 0
        <snip />
        > Before your commit, a simple warning was displayed in console: "WARNUNG:
        > Bookmarks: Unresolved ID reference 'xyz' found."

        A small oversight: since IDTracker.getPageViewportsContaining... now returns an empty list instead of null when an ID reference is not found, AreaTreeHandler needs an addition to the not-null check on line 339. Add '&& !pageVPList.isEmpty()' for an immediate fix. I will commit this to trunk soon, including the testcase.

        Show
        Andreas L. Delmelle added a comment - (In reply to comment #2) > > this commit causes a IndexOutOfBoundsException, when there are unresolved > bookmark references: > > java.lang.IndexOutOfBoundsException: Index: 0 <snip /> > Before your commit, a simple warning was displayed in console: "WARNUNG: > Bookmarks: Unresolved ID reference 'xyz' found." A small oversight: since IDTracker.getPageViewportsContaining... now returns an empty list instead of null when an ID reference is not found, AreaTreeHandler needs an addition to the not-null check on line 339. Add '&& !pageVPList.isEmpty()' for an immediate fix. I will commit this to trunk soon, including the testcase.
        Hide
        Matthias Reischenbacher added a comment -

        Attachment toc-error.xml has been added with description: Testcase

        Show
        Matthias Reischenbacher added a comment - Attachment toc-error.xml has been added with description: Testcase
        Hide
        Matthias Reischenbacher added a comment -

        Testcase for reproducing the previously mentioned exception.

        Show
        Matthias Reischenbacher added a comment - Testcase for reproducing the previously mentioned exception.
        Hide
        Matthias Reischenbacher added a comment -

        Andreas,

        this commit causes a IndexOutOfBoundsException, when there are unresolved bookmark references:

        java.lang.IndexOutOfBoundsException: Index: 0
        at java.util.Collections$EmptyList.get(Collections.java:2970)
        at org.apache.fop.area.BookmarkData.resolveIDRef(BookmarkData.java:225)
        at org.apache.fop.area.BookmarkData.resolveIDRef(BookmarkData.java:233)
        at org.apache.fop.area.AreaTreeHandler.addOffDocumentItem(AreaTreeHandler.java:340)
        at org.apache.fop.area.AreaTreeHandler.endDocument(AreaTreeHandler.java:311)
        at org.apache.fop.fo.FOTreeBuilder.endDocument(FOTreeBuilder.java:164)
        at org.apache.xalan.transformer.TransformerIdentityImpl.endDocument(TransformerIdentityImpl.java:963)
        at org.apache.xml.serializer.TreeWalker.traverse(TreeWalker.java:176)
        at org.apache.xalan.transformer.TransformerIdentityImpl.transform(TransformerIdentityImpl.java:390)

        Before your commit, a simple warning was displayed in console: "WARNUNG: Bookmarks: Unresolved ID reference 'xyz' found."

        I'm attaching a simple test case which reproduces the error.

        Show
        Matthias Reischenbacher added a comment - Andreas, this commit causes a IndexOutOfBoundsException, when there are unresolved bookmark references: java.lang.IndexOutOfBoundsException: Index: 0 at java.util.Collections$EmptyList.get(Collections.java:2970) at org.apache.fop.area.BookmarkData.resolveIDRef(BookmarkData.java:225) at org.apache.fop.area.BookmarkData.resolveIDRef(BookmarkData.java:233) at org.apache.fop.area.AreaTreeHandler.addOffDocumentItem(AreaTreeHandler.java:340) at org.apache.fop.area.AreaTreeHandler.endDocument(AreaTreeHandler.java:311) at org.apache.fop.fo.FOTreeBuilder.endDocument(FOTreeBuilder.java:164) at org.apache.xalan.transformer.TransformerIdentityImpl.endDocument(TransformerIdentityImpl.java:963) at org.apache.xml.serializer.TreeWalker.traverse(TreeWalker.java:176) at org.apache.xalan.transformer.TransformerIdentityImpl.transform(TransformerIdentityImpl.java:390) Before your commit, a simple warning was displayed in console: "WARNUNG: Bookmarks: Unresolved ID reference 'xyz' found." I'm attaching a simple test case which reproduces the error.
        Hide
        Andreas L. Delmelle added a comment -


        No objections, I assumed, so I went ahead and committed in r1062901 ( http://svn.apache.org/viewvc?rev=1062901&view=rev ).

        Show
        Andreas L. Delmelle added a comment - No objections, I assumed, so I went ahead and committed in r1062901 ( http://svn.apache.org/viewvc?rev=1062901&view=rev ).
        Hide
        Andreas L. Delmelle added a comment -

        Attachment fop_area.diff has been added with description: diff of the affected classes

        Show
        Andreas L. Delmelle added a comment - Attachment fop_area.diff has been added with description: diff of the affected classes

          People

          • Assignee:
            fop-dev
            Reporter:
            Andreas L. Delmelle
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development