Uploaded image for project: 'CXF'
  1. CXF
  2. CXF-4437

Stack Overflow exception in org.apache.cxf.endpoint.ClientImpl when logging set to FINE

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 2.6.1
    • 2.4.9, 2.5.5, 2.6.2, 2.7
    • Core
    • None
    • JDK 1.6.0_32

    • Unknown

    Description

      Hi,

      I can reproduce the issue in our code, but will probably struggle to
      create a test case.

      I have narrowed down the culprit (in 2.6.1) to org.apache.cxf.endpoint.ClientImpl line 636

      The method protected Object[] processResult(Message message,
      Exchange exchange,
      BindingOperationInfo oi,
      Map<String, Object> resContext)
      throws Exception {

      And the code:

      if (LOG.isLoggable(Level.FINE))

      { LOG.fine("set responseContext to be" + resContext); }

      The code to add all the properties from the message to resContext, creates a recursive reference, because the message already has a reference to resContext. This causes the logging to fail as when it tries to serialise the content of the map, it gets a stack overflow.

      The org.apache.cxf.invocation.context contains the ResponseContext and
      the ResponseContext contains the org.apache.cxf.invocation.context

      To prove my hypothesis I added the following code to replace the log call:

      HashMap contextMap = (HashMap)
      resContext.get("org.apache.cxf.invocation.context");
      HashMap responseContextMap = (HashMap)
      contextMap.get("ResponseContext");
      HashMap secondContextMap = (HashMap)
      responseContextMap.get("org.apache.cxf.invocation.context");
      if (secondContextMap != null)

      { System.out.println("Oh boy here is the error!"); }

      And I got the Oh boy here is the error! message back.

      The original stack trace is:

      java.lang.StackOverflowError
      at java.util.HashMap$EntrySet.iterator(HashMap.java:950)
      at java.util.AbstractMap.toString(AbstractMap.java:478)
      at java.lang.String.valueOf(String.java:2826)
      at java.lang.StringBuilder.append(StringBuilder.java:115)
      at java.util.AbstractMap.toString(AbstractMap.java:490)
      at java.lang.String.valueOf(String.java:2826)
      at java.lang.StringBuilder.append(StringBuilder.java:115)
      at java.util.AbstractMap.toString(AbstractMap.java:490)
      at java.lang.String.valueOf(String.java:2826)
      at java.lang.StringBuilder.append(StringBuilder.java:115)
      at java.util.AbstractMap.toString(AbstractMap.java:490)
      at java.lang.String.valueOf(String.java:2826)
      at java.lang.StringBuilder.append(StringBuilder.java:115)
      at java.util.AbstractMap.toString(AbstractMap.java:490)
      at java.lang.String.valueOf(String.java:2826)
      at java.lang.StringBuilder.append(StringBuilder.java:115)
      at java.util.AbstractMap.toString(AbstractMap.java:490)
      at java.lang.String.valueOf(String.java:2826)
      at java.lang.StringBuilder.append(StringBuilder.java:115)
      at java.util.AbstractMap.toString(AbstractMap.java:490)
      at java.lang.String.valueOf(String.java:2826)
      at java.lang.StringBuilder.append(StringBuilder.java:115)
      at java.util.AbstractMap.toString(AbstractMap.java:490)
      at java.lang.String.valueOf(String.java:2826)
      at java.lang.StringBuilder.append(StringBuilder.java:115)
      at java.util.AbstractMap.toString(AbstractMap.java:490)
      at java.lang.String.valueOf(String.java:2826)
      at java.lang.StringBuilder.append(StringBuilder.java:115)
      at java.util.AbstractMap.toString(AbstractMap.java:490)

      <snip>

      Attachments

        Activity

          People

            ay Akitoshi Yoshida
            pellcorp Jason Pell
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: