Uploaded image for project: 'Spring Integration'
  1. Spring Integration
  2. INT-2931

AbstractMessageRouter.getRequiredConversionService() is not thread-safe

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Critical
    • Resolution: Complete
    • Affects Version/s: 2.2.1
    • Fix Version/s: 3.0 M1, 2.2.2
    • Component/s: Core
    • Labels:

      Description

      The method AbstractMessageRouter.getRequiredConversionService() is not thread-safe and may cause an NPE in AbstractMappingMessageRouter.addToCollection(). The method makes a call to getConversionService() and sets a default conversion service if the it returns null. However, getConversionService() does also make an attempt to set a conversion service in case one is defined in the application context. Otherwise it sets it to null. If these methods are called by multiple threads and the timing is bad, the conversion service will be set to null in getConversionService() after it was initialized in getRequiredConversionService().

      Since the conversion service is a volatile field in IntegrationObjectSupport, double-checked locking in both methods would solve the problem. An alternative solution might be initializing the conversion service in AbstractMessageRouter.onInit().

      Attached to this issue you will find a unit test to reproduce this problem with a debugger. A pull request solving this issue with double-checked locking will follow in a few minutes.

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              grussell Gary Russell
              Reporter:
              sferstl Stefan Ferstl
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved: