/[Apache-SVN]
ViewVC logotype

Revision 1075322


Jump to revision: Previous Next
Author: sascharodekamp
Date: Mon Feb 28 13:43:23 2011 UTC (13 years, 2 months ago)
Changed paths: 23
Log Message:
Improvement - if-regexp conditions in Minilang and Screens not thread safe (https://issues.apache.org/jira/browse/OFBIZ-4107). I added another getTestPattern Method to support case insensitive tests. The case insensitive testPattern is needed from the UtilHttp.checkURLforSpiders.

Thanks Martin & Dimitri for your effort.

Orig. Msg.:

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


Changed paths

Path Details
Directoryofbiz/trunk/framework/base/src/org/ofbiz/base/util/CompilerMatcher.java added
Directoryofbiz/trunk/framework/base/src/org/ofbiz/base/util/UtilHttp.java modified , text changed
Directoryofbiz/trunk/framework/entity/src/org/ofbiz/entity/condition/EntityComparisonOperator.java modified , text changed
Directoryofbiz/trunk/framework/minilang/build.xml modified , text changed
Directoryofbiz/trunk/framework/minilang/ofbiz-component.xml modified , text changed
Directoryofbiz/trunk/framework/minilang/script/ added
Directoryofbiz/trunk/framework/minilang/script/org/ added
Directoryofbiz/trunk/framework/minilang/script/org/ofbiz/ added
Directoryofbiz/trunk/framework/minilang/script/org/ofbiz/minilang/ added
Directoryofbiz/trunk/framework/minilang/script/org/ofbiz/minilang/method/ added
Directoryofbiz/trunk/framework/minilang/script/org/ofbiz/minilang/method/ifops/ added
Directoryofbiz/trunk/framework/minilang/script/org/ofbiz/minilang/method/ifops/IfRegexpTests.xml added
Directoryofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/conditional/RegexpCondition.java modified , text changed
Directoryofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/ifops/IfRegexp.java modified , text changed
Directoryofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/ifops/test/ added
Directoryofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/ifops/test/IfRegexpTest.java added
Directoryofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/operation/Regexp.java modified , text changed
Directoryofbiz/trunk/framework/minilang/testdef/ added
Directoryofbiz/trunk/framework/minilang/testdef/MinilangTests.xml added
Directoryofbiz/trunk/framework/widget/src/org/ofbiz/widget/form/ModelFormField.java modified , text changed
Directoryofbiz/trunk/framework/widget/src/org/ofbiz/widget/menu/ModelMenuCondition.java modified , text changed
Directoryofbiz/trunk/framework/widget/src/org/ofbiz/widget/screen/ModelScreenCondition.java modified , text changed
Directoryofbiz/trunk/framework/widget/src/org/ofbiz/widget/tree/ModelTreeCondition.java modified , text changed

infrastructure at apache.org
ViewVC Help
Powered by ViewVC 1.1.26