Uploaded image for project: 'OFBiz'
  1. OFBiz
  2. OFBIZ-4107

if-regexp conditions in Minilang and Screens not thread safe

Attach filesAttach ScreenshotVotersWatch issueWatchersCreate sub-taskLinkCloneUpdate Comment AuthorReplace String in CommentUpdate Comment VisibilityDelete Comments
    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • Trunk
    • Trunk
    • framework
    • None

    Description

      The Perl5Matcher Perl5Compiler are not thread safe, as mentioned in their documentation: http://jakarta.apache.org/oro/api/org/apache/oro/text/regex/Perl5Compiler.html
      A separate instance should be used per thread.

      The concrete issue occurred in our system in the createCommContentDataResource service. The service tries to save emails to the database after they have been sent. It failed because of the described issue. This caused the whole email service (sendMailFromScreen) to be rescheduled. So customers got emails twice.

      The Perl5Matcher and Perl5Compiler instances are assigned to static fields in the org.ofbiz.minilang.method.ifops.IfRegexp class. So every thread will use the same instance. No synchronization is done currently. Changing the fields to be non-static will not work either, as SimpleMethods are cached. So all calls to the same simple method use the same IfRegexp instance.

      We fixed the problem by moving the instantiation of the Perl5Matcher and Perl5Compiler to the exec() method in IfRegexp.

      Other classes are most likely affected, too: org.ofbiz.entity.condition.EntityComparisonOperator, org.ofbiz.minilang.method.conditional.RegexpCondition, org.ofbiz.minilang.operation.Regexp, org.ofbiz.widget.menu.ModelMenuCondition$IfRegexp, org.ofbiz.widget.screen.ModelScreenCondition$IfRegexp, org.ofbiz.widget.tree.ModelTreeCondition$IfRegexp

      Attachments

        1. OFBIZ-4107-test.patch
          7 kB
          Martin Kreidenweis
        2. OFBIZ-4107-partial-fix.patch
          0.9 kB
          Martin Kreidenweis
        3. OFBIZ-4107.patch
          25 kB
          Dimitri Unruh

        Activity

          This comment will be Viewable by All Users Viewable by All Users
          Cancel

          People

            sascha Sascha Schumann
            mkreidenweis Martin Kreidenweis
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Slack

                Issue deployment