Btw, the outer if block is not necessary. FSE instance creation is
optimized and it follows the NULL pattern, so you can do this:
String s = FlexibleStringExpander.expandString(this.envName, context);
if (!s.isEmpty()) {
value = s;
}
If this.envName is null or empty, FSE will return an empty String.
Adrian Crum
Sandglass Software
www.sandglass-software.com
On 1/14/2015 12:40 AM, [email protected] wrote:
Author: jacopoc
Date: Wed Jan 14 08:40:08 2015
New Revision: 1651593
URL: http://svn.apache.org/r1651593
Log:
Since ServiceEcaSetField are cached, if a seca definition contains a set
operation with an env-name like:
<set field-name="partyId" env-name="${userLogin.partyId}"/>
then the expanded value (at the time of creation) is stored in the
ServiceEcaSetField and then reused even when the seca is re-executed with a
different context.
This commit fix the bug by removing the outer if statement "if
(UtilValidate.isEmpty(this.value))".
Thanks to Deepak Dixit for spotting this issue.
Modified:
ofbiz/trunk/framework/service/src/org/ofbiz/service/eca/ServiceEcaSetField.java
Modified:
ofbiz/trunk/framework/service/src/org/ofbiz/service/eca/ServiceEcaSetField.java
URL:
http://svn.apache.org/viewvc/ofbiz/trunk/framework/service/src/org/ofbiz/service/eca/ServiceEcaSetField.java?rev=1651593&r1=1651592&r2=1651593&view=diff
==============================================================================
---
ofbiz/trunk/framework/service/src/org/ofbiz/service/eca/ServiceEcaSetField.java
(original)
+++
ofbiz/trunk/framework/service/src/org/ofbiz/service/eca/ServiceEcaSetField.java
Wed Jan 14 08:40:08 2015
@@ -56,15 +56,13 @@ public class ServiceEcaSetField {
public void eval(Map<String, Object> context) {
if (fieldName != null) {
// try to expand the envName
- if (UtilValidate.isEmpty(this.value)) {
- if (UtilValidate.isNotEmpty(this.envName) &&
this.envName.startsWith("${")) {
- FlexibleStringExpander exp =
FlexibleStringExpander.getInstance(this.envName);
- String s = exp.expandString(context);
- if (UtilValidate.isNotEmpty(s)) {
- value = s;
- }
- Debug.logInfo("Expanded String: " + s, module);
+ if (UtilValidate.isNotEmpty(this.envName) &&
this.envName.startsWith("${")) {
+ FlexibleStringExpander exp =
FlexibleStringExpander.getInstance(this.envName);
+ String s = exp.expandString(context);
+ if (UtilValidate.isNotEmpty(s)) {
+ value = s;
}
+ Debug.logInfo("Expanded String: " + s, module);
}
// TODO: rewrite using the ContextAccessor.java see hack below to
be able to use maps for email notifications
// check if target is a map and create/get from contaxt