Bug 54068 - Web fragment sorting incorrectly detects circular reference
Web fragment sorting incorrectly detects circular reference
Status: RESOLVED FIXED
Product: Tomcat 7
Classification: Unclassified
Component: Catalina
7.0.32
PC All
: P2 normal with 14 votes (vote)
: ---
Assigned To: Tomcat Developers Mailing List
:
Depends on:
Blocks:
  Show dependency tree
 
Reported: 2012-10-30 05:30 UTC by Dennis Homann
Modified: 2012-10-31 22:10 UTC (History)
0 users



Attachments
Test case implementation (1.70 KB, patch)
2012-10-30 05:30 UTC, Dennis Homann
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Dennis Homann 2012-10-30 05:30:27 UTC
Created attachment 29522 [details]
Test case implementation

The implementation of web fragment sorting with relative ordering constraints may detect circular references, even though there is no such circle. 

This occurrence of this bug depends on the iteration order of the input map.

Consider the attached test case, defining a simple chain of three web fragments:
* web fragments a, b, c, with relative constraints "b after a", "c after b".
* expected result: a, b, c
* actual result: 

Testcase: testOrderWebFragmentsRelative4 took 0,002 sec
        Caused an ERROR
Fragment relative ordering contains circular references. Thsi can be resolved by using absolute ordering in web.xml.
java.lang.IllegalArgumentException: Fragment relative ordering contains circular references. Thsi can be resolved by using absolute ordering in web.xml.
        at org.apache.catalina.deploy.WebXml.orderWebFragments(WebXml.java:2190)
        at org.apache.catalina.deploy.TestWebXmlOrdering.testOrderWebFragmentsRelative4(TestWebXmlOrdering.java:268)

Workaround: use absolute ordering.

Details:
* Java 1.7.0_07
Comment 1 Mark Thomas 2012-10-30 08:38:33 UTC
Comment on attachment 29522 [details]
Test case implementation

Fix MIME type
Comment 2 Mark Thomas 2012-10-31 22:07:30 UTC
What a lovely can of worms that was. All my own fault since I wrote the broken algorithm in the first place.

I have re-written the sorting algorithm to address the issue identified in this report and a handful of other problems that emerged as I started to look for ways to break the existing algorithm.

The test cases for relative ordering have be re-written so they test all 720 possible combinations of input order for each test and I have increased the number of test cases including several to cover the ordering highlighted in this test case.

The fix has been made to trunk and 7.0.x and will be included in 7.0.33 onwards.
Comment 3 Dennis Homann 2012-10-31 22:10:43 UTC
Great, thank you!