Uploaded image for project: 'Camel'
  1. Camel
  2. CAMEL-11983

XsltAggregationStrategy thread safety during initialization

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: 2.20.0
    • Fix Version/s: 2.19.5, 2.20.1, 2.21.0
    • Component/s: camel-xslt
    • Labels:
    • Environment:

      Apache Camel 2.17 on EAP Fuse 6.4.0
      Apache Camel 2.20 on Spring Boot standalone

    • Estimated Complexity:
      Unknown

      Description

      It seems that there is a race condition in the XsltAggregatorStrategy. The following code:

      
      if (xslt == null) {
          initialize(oldExchange.getContext());
      }
      ...
      xslt.process(oldExchange);
      
      

      means that potentially one thread might be still working on the initialize call while another thread passes through the gate of the if statement and executes the xslt.process() call. If the initialization is not quite complete, the XsltBuilder will throw an exception complaining that the template has not been set.

      I have written a small Spring Boot project (which I am attaching to this Jira issue) that demonstrates this. I understand that this only happens when parallelization is present during the xslt member initialization above, and that it sorts itself out in subsequent calls, but I have managed to see this during testing, so it is not that impossible for it to happen.

        Attachments

        1. reentrancy.zip
          82 kB
          Pafsanias Ftakas

          Issue Links

            Activity

              People

              • Assignee:
                davsclaus Claus Ibsen
                Reporter:
                salagator Pafsanias Ftakas
              • Votes:
                0 Vote for this issue
                Watchers:
                2 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: