Uploaded image for project: 'PUBLIC - Liferay Faces'
  1. PUBLIC - Liferay Faces
  2. FACES-1338

Failure in TCK TestPage183: getApplicationMapTest

    Details

      Description

      The getApplicationMapTest calls PortletContext.getAttributeNames() and then compares the names/values with the Map returned by ExternalContext.getApplicationMap().

      The test failure occurs if there has been a postback issued during a prior test. When that happens, then the BridgeRequestScopeManagerImpl class will store an attribute named "com.liferay.faces.bridge.bridgeRequestScopeCache" in the Map. As the test is iterating through all of the attributes, it calls the ".equals(Object)" method on the BridgeRequestScopeCache Map. Since the BridgeRequestScopeCache Map is wrapped by Collections.synchronizedMap(Map), a ConcurrentModificationException gets thrown:

      java.util.ConcurrentModificationException
      	at java.util.LinkedHashMap$LinkedHashIterator.nextEntry(LinkedHashMap.java:373)
      	at java.util.LinkedHashMap$EntryIterator.next(LinkedHashMap.java:392)
      	at java.util.LinkedHashMap$EntryIterator.next(LinkedHashMap.java:391)
      	at java.util.AbstractMap.equals(AbstractMap.java:420)
      	at java.util.Collections$SynchronizedMap.equals(Collections.java:2020)
      	at org.apache.myfaces.portlet.faces.testsuite.tests.chapter_6.section_6_1_3_2.Tests.containsIdenticalAttributeEntries(Tests.java:224)
      	at org.apache.myfaces.portlet.faces.testsuite.tests.chapter_6.section_6_1_3_2.Tests.getApplicationMapTest(Tests.java:147)
      

      Steps to reproduce the problem:

      1. Click on "TestPage183"
      2. Verify that the test page reports success
      3. Click on "TestPage179"
      4. Click on the "Run Test" button, which will invoke a postback and create the BridgeRequestScopeCache
      5. Click on the "TestPage180" button
      6. Click on the "Run Test" button
      (note that steps 5 and 6 are probably not necessary, but those are the steps that I followed when reproducing the bug)
      7. Click back on "TestPage183"

      If the bug still exists, then the aforementioned exception will get thrown. If the bug is fixed, then the test page will report success.

      The solution to this problem is to stop using Collections.synchronizedMap and instead, have the BridgeRequestScopeCache extend ConcurrentHashMap. This will fix the ConcurrentModificationException, as described in the article Concurrent Collections.

        Attachments

          Activity

            People

            • Assignee:
              neil.griffin Neil Griffin
              Reporter:
              neil.griffin Neil Griffin
              Participants of an Issue:
            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Packages

                Version Package
                liferay-faces-3.0.0-legacy-ga1
                liferay-faces-3.0.0-ga1
                liferay-faces-3.1.0-ga1